dit.shannon
The basic forms of Shannon’s information measures.
Functions
Returns the conditional entropy of H[X|Y]. |
|
Returns the entropy H[X] over the random variables in rvs. |
|
Returns the entropy of the probability mass function. |
|
Returns the mutual information I[X:Y]. |
Reference
- conditional_entropy(dist, rvs_X, rvs_Y)[source]
Returns the conditional entropy of H[X|Y].
If the distribution represents linear probabilities, then the entropy is calculated with units of ‘bits’ (base-2).
- Parameters:
dist (Distribution) – The distribution from which the conditional entropy is calculated.
rvs_X (list, None) – The indexes of the random variables defining X.
rvs_Y (list, None) – The indexes of the random variables defining Y.
- Returns:
H_XgY – The conditional entropy H[X|Y].
- Return type:
- entropy(dist, rvs=None)[source]
Returns the entropy H[X] over the random variables in rvs.
If the distribution represents linear probabilities, then the entropy is calculated with units of ‘bits’ (base-2). Otherwise, the entropy is calculated in whatever base that matches the distribution’s pmf.
- Parameters:
dist (Distribution or float) – The distribution from which the entropy is calculated. If a float, then we calculate the binary entropy.
rvs (list, None) – The indexes of the random variable used to calculate the entropy. If None, then the entropy is calculated over all random variables. This should remain None for scalar distributions.
- Returns:
H – The entropy of the distribution.
- Return type:
- entropy_pmf(pmf)[source]
Returns the entropy of the probability mass function.
Assumption: Linearly distributed probabilities.
- Parameters:
pmf (NumPy array, shape (k,) or (n,k)) – Returns the entropy over the last index.
- mutual_information(dist, rvs_X, rvs_Y)[source]
Returns the mutual information I[X:Y].
If the distribution represents linear probabilities, then the entropy is calculated with units of ‘bits’ (base-2).
- Parameters:
dist (Distribution) – The distribution from which the mutual information is calculated.
rvs_X (list, None) – The indexes of the random variables defining X.
rvs_Y (list, None) – The indexes of the random variables defining Y.
- Returns:
I – The mutual information I[X:Y].
- Return type: