bundles / scipy latest / scipy / stats / _probability_distribution / _ProbabilityDistribution / logentropy
function
scipy.stats._probability_distribution:_ProbabilityDistribution.logentropy
Signature
def logentropy ( self , * , method ) Summary
Logarithm of the 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.
logentropy computes the logarithm of the differential entropy ("log-entropy"), , but it may be numerically favorable compared to the naive implementation (computing then taking the logarithm).
Parameters
method: {None, 'formula', 'logexp', 'quadrature}The strategy used to evaluate the log-entropy. By default (
None), the infrastructure chooses between the following options, listed in order of precedence.'formula': use a formula for the log-entropy itself'logexp': evaluate the entropy and take the logarithm'quadrature': numerically log-integrate (or, in the discrete case, log-sum) the logarithm of the entropy integrand (summand)
Not all
methodoptions are available for all distributions. If the selectedmethodis not available, aNotImplementedErrorwill be raised.
Returns
out: arrayThe log-entropy.
Notes
The differential entropy of a continuous distribution can be negative. In this case, the log-entropy is complex with imaginary part . For consistency, the result of this function always has complex dtype, regardless of the value of the imaginary part.
Examples
Instantiate a distribution with the desired parameters:import numpy as np from scipy import stats X = stats.Uniform(a=-1., b=1.)✓
X.logentropy()
✗np.allclose(np.exp(X.logentropy()), X.entropy())
✓X = stats.Uniform(a=-.1, b=.1)
✓X.entropy(), X.logentropy()
✗See also
Aliases
-
scipy.stats._distribution_infrastructure._ProbabilityDistribution.logentropy