Represents a probability mass function.
Values can be any hashable type; probabilities are floating-point.
Pmfs are not necessarily normalized.
@Params:
param | type | description |
---|---|---|
values | string | array |
name | string | sequence of values |
@Methods:
Important: This class inherits from DictWrapper, so you can use all methods of the parent class.
Gets the probability associated with the value x.
@Params:
param | type | description |
---|---|---|
x | any | number value |
probDefault | number | value to return if the key is not there |
@Returns: probability
Gets probabilities for a sequence of values.
@Params:
param | type | description |
---|---|---|
xs | array | a sequence of values |
@Returns: array of probabilities
Makes a cdf.
@Params:
param | type | description |
---|---|---|
name | string | the name for new cdf |
@Returns: one new cdf
Calculate the probability while the value is greater than x.
@Params:
param | type | description |
---|---|---|
x | number |
@Returns: probability
Calculate the probability while the value is less than x.
@Params:
param | type | description |
---|---|---|
x | number |
@Returns: probability
Normalizes this PMF so the sum of all probs is fraction.
@Params:
param | type | description |
---|---|---|
fraction | number | what the total should be after normalization |
@Returns: the total probability before normalizing
Chooses a random element from this PMF.
@Returns: float value from the pmf
Computes the mean of a PMF.
@Returns: float mean
Computes the variance of a PMF.
@Params:
param | type | description |
---|---|---|
miu | number | the point around which the variance is computed; if omitted, computes the mean |
@Returns: float variance
Returns the value with the highest probability.
@Returns: float probability
Computes the central credible interval.
If percentage=90, computes the 90% CI.
@Params:
param | type | description |
---|---|---|
percentage | number | float between 0 and 100 |
@Returns: sequence of two floats, low and high
Computes the Pmf of the sum of values drawn from self and other.
@Params:
param | type | description |
---|---|---|
other | number | pmf |
@Returns: new pmf
Computes the Pmf of the sum of values drawn from self and other.
@Params:
param | type | description |
---|---|---|
other | pmf | another pmf |
@Returns: new pmf
Computes the Pmf of the sum a constant and values from self.
@Params:
param | type | description |
---|---|---|
other | number | a number |
@Returns: new pmf
Computes the Pmf of the diff of values drawn from self and other.
@Params:
param | type | description |
---|---|---|
other | pmf | another pmf |
@Returns: new pmf
Computes the CDF of the maximum of k selections from this dist.
@Params:
param | type | description |
---|---|---|
k | number | int |
@Returns: new cdf