pomdp_py.representations.distribution package¶
pomdp_py.representations.distribution.histogram module¶
- class pomdp_py.representations.distribution.histogram.Histogram¶
Bases:
GenerativeDistribution
Histogram representation of a probability distribution.
__init__(self, histogram)
- Parameters:
histogram (dict) – variable value to probability
- __getitem__(self, value)¶
Returns the probability of value.
- __setitem__(self, value, prob)¶
Sets probability of value to prob.
- get_histogram(self)¶
Returns a dictionary from value to probability of the histogram
- histogram¶
- is_normalized(epsilon=1e-09)¶
Returns true if this distribution is normalized
- mpe(self)¶
Returns the most likely value of the variable.
- random(self)¶
Randomly sample a value based on the probability in the histogram
pomdp_py.representations.distribution.particles module¶
- class pomdp_py.representations.distribution.particles.Particles¶
Particles is a set of unweighted particles; This set of particles represent a distribution \(\Pr(X)\). Each particle takes on a specific value of \(X\). Inherits
WeightedParticles
.__init__(self, particles, **kwargs)
- Parameters:
particles (list) – List of values.
kwargs – see __init__() of
WeightedParticles
.
- add(self, particle)¶
particle: just a value
- classmethod from_histogram(histogram, num_particles=1000)¶
Given a pomdp_py.Histogram return a particle representation of it, which is an approximation
- get_abstraction(self, state_mapper)¶
feeds all particles through a state abstraction function. Or generally, it could be any function.
- get_histogram(self)¶
Returns a mapping from value to probability, normalized.
- particles¶
For unweighted particles, the particles are just values.
- random()¶
Samples a value based on the particles
- class pomdp_py.representations.distribution.particles.WeightedParticles¶
Represents a distribution \(\Pr(X)\) with weighted particles, each is a tuple (value, weight). “value” means a value for the random variable X. If multiple values are present for the same value, will interpret the probability at X=x as the average of those weights.
__init__(self, list particles, str approx_method=”none”, distance_func=None)
- Parameters:
particles (list) – List of (value, weight) tuples. The weight represents the likelihood that the value is drawn from the underlying distribution.
approx_method (str) – ‘nearest’ if when querying the probability of a value, and there is no matching particle for it, return the probability of the value closest to it. Assuming values are comparable; “none” if no approximation, return 0.
distance_func – Used when approx_method is ‘nearest’. Returns a number given two values in this particle set.
frozen – if true, then this WeightedParticles object cannot be modified. This makes it hashable.
- __getitem__()¶
Returns the probability of value; normalized
- __setitem__()¶
The particle belief does not support assigning an exact probability to a value.
- add(self, particle)¶
particle: (value, weight) tuple
- condense()¶
Returns a new set of weighted particles with unique values and weights aggregated (taken average).
- classmethod from_histogram(histogram, frozen=False)¶
Given a pomdp_py.Histogram return a particle representation of it, which is an approximation
- frozen¶
- get_histogram(self)¶
Returns a mapping from value to probability, normalized.
- hist¶
- hist_valid¶
- mpe(self)¶
Returns the value of the variable that has the highest probability.
- particles¶
- random()¶
Samples a value based on the particles
- values¶
- weights¶
pomdp_py.representations.distribution.gaussian module¶
- class pomdp_py.representations.distribution.gaussian.Gaussian¶
Bases:
GenerativeDistribution
Note that Gaussian distribution is defined over a vector of numerical variables, but not a State variable.
__init__(self, mean, cov)
- __getitem__(self, value)¶
Evaluate the probability of given value
- Parameters:
value (list or array like) –
- Returns:
The density of multivariate Gaussian.
- Return type:
float
- __setitem__(self, value, prob)¶
Not Implemented; It isn’t supported to arbitrarily change a value in a Gaussian distribution to have a given probability.
- cov¶
- covariance¶
- mean¶
- mpe(self)¶
- random(self, n=1)¶
- sigma¶