Inherits from
- basemodel: scipy.maxentropy.maxentropy.basemodel
Attributes
- probdist
An alias for pmf
probdist = pmf
Method summary
- __init__(self, f = None, samplespace = None)
- expectations(self)
- lognormconst(self)
- logpmf(self)
- pmf(self)
- pmf_function(self, f = None)
- setfeaturesandsamplespace(self, f, samplespace)
Methods
- __init__(self, f = None, samplespace = None)
- expectations(self)
The vector E_p[f(X)] under the model p_params of the vector of feature functions f_i over the sample space.
- lognormconst(self)
Compute the log of the normalization constant (partition function) Z=sum_{x in samplespace} p_0(x) exp(params . f(x)). The sample space must be discrete and finite.
- logpmf(self)
Returns an array indexed by integers representing the logarithms of the probability mass function (pmf) at each point in the sample space under the current model (with the current parameter vector self.params).
- pmf(self)
Returns an array indexed by integers representing the values of the probability mass function (pmf) at each point in the sample space under the current model (with the current parameter vector self.params).
Equivalent to exp(self.logpmf())
- pmf_function(self, f = None)
Returns the pmf p_theta(x) as a function taking values on the model's sample space. The returned pmf is defined as: p_theta(x) = exp(theta.f(x) - log Z) where theta is the current parameter vector self.params. The returned function p_theta also satisfies all([p(x) for x in self.samplespace] == pmf()). The feature statistic f should be a list of functions [f1(),...,fn(x)]. This must be passed unless the model already contains an equivalent attribute 'model.f'. Requires that the sample space be discrete and finite, and stored as self.samplespace as a list or array. - setfeaturesandsamplespace(self, f, samplespace)
Creates a new exponential model, where f is a list of feature functions f_i mapping the sample space to real values. The parameter vector params is initialized to the zero vector, of the same length as the list of feature functions f_i.
We also compute f(x) for each x in the sample space and store them as self.F. This uses lots of memory but is much faster.
This is only appropriate when the sample space is finite.
