bundles / scipy 1.17.1 / scipy / stats / _probability_distribution / _ProbabilityDistribution / entropy
function
scipy.stats._probability_distribution:_ProbabilityDistribution.entropy
Signature
def entropy ( self , * , method ) Summary
Differential entropy
Extended Summary
In terms of probability density function and support , the differential entropy (or simply "entropy") of a continuous random variable is:
The definition for a discrete random variable is analogous, with the PMF replacing the PDF and a sum over the support replacing the integral.
Parameters
method: {None, 'formula', 'logexp', 'quadrature'}The strategy used to evaluate the entropy. By default (
None), the infrastructure chooses between the following options, listed in order of precedence.'formula': use a formula for the entropy itself'logexp': evaluate the log-entropy and exponentiate'quadrature': numerically integrate (or, in the discrete case, sum) the entropy integrand (summand)
Not all
methodoptions are available for all distributions. If the selectedmethodis not available, aNotImplementedErrorwill be raised.
Returns
out: arrayThe entropy of the random variable.
Notes
This function calculates the entropy using the natural logarithm; i.e. the logarithm with base . Consequently, the value is expressed in (dimensionless) "units" of nats. To convert the entropy to different units (i.e. corresponding with a different base), divide the result by the natural logarithm of the desired base.
Examples
Instantiate a distribution with the desired parameters:from scipy import stats X = stats.Uniform(a=-1., b=1.)✓
X.entropy()
✗See also
Aliases
-
scipy.stats._distribution_infrastructure._ProbabilityDistribution.entropy