Frozen Distribution
In scipy.stats
you can create a frozen distribution that allows the parameterization (shape, location & scale) of the distribution to be permanently set for that instance.
For example, you can create an gamma distribution (scipy.stats.gamma
) with a
,loc
and scale
parameters and freeze them so they do not have to be passed around every time that distribution is needed.
import scipy.stats as stats
# Parameters for this particular gamma distribution
a, loc, scale = 3.14, 5.0, 2.0
# Do something with the general distribution parameterized
print 'gamma stats:', stats.gamma(a, loc=loc, scale=scale).stats()
# Create frozen distribution
rv = stats.gamma(a, loc=loc, scale=scale)
# Do something with the specific, already parameterized, distribution
print 'rv stats :', rv.stats()
gamma stats: (array(11.280000000000001), array(12.56))
rv stats : (array(11.280000000000001), array(12.56))
Accessible rv
parameters?
Since the parameters will most likely not be passed around as a result of this feature, is there a way to get those values back from only the frozen distribution, rv
, later on?
Aucun commentaire:
Enregistrer un commentaire