dit.other
Esoteric measures of information, typically fairly divorced from Shannon’s measures.
Functions
Compute the LMPR complexity. |
|
Returns the conditional cumulative residual entropy. |
|
Returns the conditional cumulative residual entropy. |
|
The cumulative residual entropy is an alternative to the Shannon differential entropy with several desirable properties including non-negativity. |
|
Compute the (normalized) disequilibrium as measured the Jensen-Shannon divergence from an equilibrium distribution. |
|
Returns the extropy J[X] over the random variables in rvs. |
|
The generalized cumulative residual entropy is a generalized from of the cumulative residual entropy. |
|
Computes the lautum information. |
|
Maximal leakage from |
|
Compute the negentropy of a distribution. |
|
Compute the Renyi entropy of order order. |
|
Conditional Sibson MI minimizing over |
|
Conditional Sibson MI minimizing over |
|
Compute the Sibson mutual information of order |
|
Compute the Sibson mutual information of order |
|
Compute the Tsallis entropy of order order. |
Reference
- LMPR_complexity(dist, rvs=None)[source]
Compute the LMPR complexity.
- Parameters:
dist (Distribution) – Distribution to compute the LMPR complexity of.
rvs (list, None) – The indexes of the random variable used to calculate the LMPR complexity. If None, then the LMPR complexity is calculated over all variables. This should remain None for scalar distributions.
- Returns:
C – The LMPR complexity.
- Return type:
- conditional_cumulative_residual_entropy(dist, rv, crvs=None)[source]
Returns the conditional cumulative residual entropy.
- Parameters:
dist (Distribution) – The distribution to compute the conditional cumulative residual entropy of.
rv (list, None) – The possibly joint random variable to compute the conditional cumulative residual entropy of. If None, then all variables not in crvs are used.
crvs (list, None) – The random variables to condition on. If None, nothing is conditioned on.
- Returns:
CCRE – The conditional cumulative residual entropy.
- Return type:
Examples
>>> from itertools import product >>> events = [ (a, b) for a, b, in product(range(5), range(5)) if a <= b ] >>> probs = [ 1/(5-a)/5 for a, b in events ] >>> d = Distribution(events, probs) >>> print(conditional_cumulative_residual_entropy(d, 1, [0])) Class: Distribution Alphabet: (-0.0, 0.5, 0.91829583405448956, 1.3112781244591329, 1.6928786893420307) Base: linear
x p(x) -0.0 0.2 0.5 0.2 0.918295834054 0.2 1.31127812446 0.2 1.69287868934 0.2
- conditional_generalized_cumulative_residual_entropy(dist, rv, crvs=None)[source]
Returns the conditional cumulative residual entropy.
- Parameters:
dist (Distribution) – The distribution to compute the conditional generalized cumulative residual entropy of.
rv (list, None) – The possibly joint random variable to compute the conditional generalized cumulative residual entropy of. If None, then all variables not in crvs are used.
crvs (list, None) – The random variables to condition on. If None, nothing is conditioned on.
- Returns:
CCRE – The conditional cumulative residual entropy.
- Return type:
Examples
>>> from itertools import product >>> events = [ (a-2, b-2) for a, b, in product(range(5), range(5)) if a <= b ] >>> probs = [ 1/(3-a)/5 for a, b in events ] >>> d = Distribution(events, probs) >>> print(conditional_generalized_cumulative_residual_entropy(d, 1, [0])) Class: Distribution Alphabet: (-0.0, 0.5, 0.91829583405448956, 1.3112781244591329, 1.6928786893420307) Base: linear
x p(x) -0.0 0.2 0.5 0.2 0.918295834054 0.2 1.31127812446 0.2 1.69287868934 0.2
- cumulative_residual_entropy(dist, extract=False)[source]
The cumulative residual entropy is an alternative to the Shannon differential entropy with several desirable properties including non-negativity.
- Parameters:
dist (Distribution) – The distribution to compute the cumulative residual entropy of each index for.
extract (bool) – If True and dist.outcome_length() is 1, return the single GCRE value rather than a length-1 array.
- Returns:
CREs – The cumulative residual entropy for each index.
- Return type:
ndarray
Examples
>>> d1 = Distribution([1, 2, 3, 4, 5, 6], [1/6]*6) >>> d2 = Distribution([1, 2, 3, 4, 5, 100], [1/6]*6) >>> cumulative_residual_entropy(d1) 2.0683182557028439 >>> cumulative_residual_entropy(d2) 42.566064100334294
- disequilibrium(dist, rvs=None)[source]
Compute the (normalized) disequilibrium as measured the Jensen-Shannon divergence from an equilibrium distribution.
- Parameters:
dist (Distribution) – Distribution to compute the disequilibrium of.
rvs (list, None) – The indexes of the random variable used to calculate the diseqilibrium. If None, then the disequilibrium is calculated over all random variables. This should remain None for scalar distributions.
- Returns:
D – The disequilibrium.
- Return type:
- extropy(dist, rvs=None)[source]
Returns the extropy J[X] over the random variables in rvs.
If the distribution represents linear probabilities, then the extropy is calculated with units of ‘bits’ (base-2).
- Parameters:
dist (Distribution or float) – The distribution from which the extropy is calculated. If a float, then we calculate the binary extropy.
rvs (list, None) – The indexes of the random variable used to calculate the extropy. If None, then the extropy is calculated over all random variables. This should remain None for scalar distributions.
- Returns:
J – The extropy of the distribution.
- Return type:
- generalized_cumulative_residual_entropy(dist, extract=False)[source]
The generalized cumulative residual entropy is a generalized from of the cumulative residual entropy. Rather than integrating from 0 to infinity over the absolute value of the CDF.
- Parameters:
dist (Distribution) – The distribution to compute the generalized cumulative residual entropy of each index for.
extract (bool) – If True and dist.outcome_length() is 1, return the single GCRE value rather than a length-1 array.
- Returns:
GCREs – The generalized cumulative residual entropy for each index.
- Return type:
ndarray
Examples
>>> generalized_cumulative_residual_entropy(uniform(-2, 3)) 1.6928786893420307 >>> generalized_cumulative_residual_entropy(uniform(0, 5)) 1.6928786893420307
- lautum_information(dist, rvs=None, crvs=None)[source]
Computes the lautum information.
- Parameters:
dist (Distribution) – The distribution from which the lautum information is calculated.
rvs (list, None) – A list of lists. Each inner list specifies the indexes of the random variables used to calculate the lautum information. If None, then the lautum information is calculated over all random variables, which is equivalent to passing rvs=dist.rvs.
crvs (list, None) – A single list of indexes specifying the random variables to condition on. If None, then no variables are conditioned on.
- Returns:
L – The lautum information.
- Return type:
Examples
>>> outcomes = ['000', '001', '010', '011', '100', '101', '110', '111'] >>> pmf = [3/16, 1/16, 1/16, 3/16, 1/16, 3/16, 3/16, 1/16] >>> d = dit.Distribution(outcomes, pmf) >>> dit.other.lautum_information(d) 0.20751874963942196 >>> dit.other.lautum_information(d, rvs=[[0], [1]]) 0.0
- Raises:
ditException – Raised if dist is not a joint distribution or if rvs or crvs contain non-existent random variables.
- maximal_leakage(dist, rvs_X, rvs_Y)[source]
Maximal leakage from
XtoY.Equivalent to Sibson mutual information of order infinity.
- Parameters:
dist (Distribution) – The joint distribution.
rvs_X (list) – Indexes of the source random variables.
rvs_Y (list) – Indexes of the observed random variables.
- Returns:
L – Maximal leakage in bits.
- Return type:
- negentropy(dist, rvs=None)[source]
Compute the negentropy of a distribution.
The negentropy is the difference between the entropy of a uniform distribution over the same alphabet and the entropy of the distribution itself. It is a non-negative quantity which is zero if and only if the distribution is uniform, and quantifies how far the distribution is from uniformity.
- Parameters:
dist (Distribution) – The distribution from which the negentropy is calculated.
rvs (list, None) – The indexes of the random variables used to calculate the negentropy. If None, then the negentropy is calculated over all random variables.
- Returns:
N – The negentropy.
- Return type:
Examples
>>> d = dit.example_dists.Xor() >>> dit.other.negentropy(d) 1.0
- Raises:
ditException – Raised if rvs contain non-existant random variables.
- perplexity(dist, rvs=None, crvs=None)[source]
- Parameters:
dist (Distribution) – The distribution from which the perplexity is calculated.
rvs (list, None) – The indexes of the random variable used to calculate the perplexity. If None, then the perpelxity is calculated over all random variables.
crvs (list, None) – The indexes of the random variables to condition on. If None, then no variables are condition on.
- Returns:
P – The perplexity.
- Return type:
- renyi_entropy(dist, order, rvs=None)[source]
Compute the Renyi entropy of order order.
- Parameters:
dist (Distribution) – The distribution to take the Renyi entropy of.
order (float >= 0) – The order of the Renyi entropy.
rvs (list, None) – The indexes of the random variable used to calculate the Renyi entropy of. If None, then the Renyi entropy is calculated over all random variables.
- Returns:
H_a – The Renyi entropy.
- Return type:
- Raises:
ditException – Raised if rvs or crvs contain non-existant random variables.
ValueError – Raised if order is not a non-negative float.
- sibson_conditional_mutual_information_y_given_z(dist, rvs_X, rvs_Y, rvs_Z, order)[source]
Conditional Sibson MI minimizing over
Q_{Y|Z}(Esposito et al., Def. 3).Reduces to unconditional Sibson MI when
Zis constant (Esposito et al., Def. 3).- Parameters:
dist (Distribution) – The joint distribution over
X,Y, andZ.rvs_X (list) – Indexes defining each variable group.
rvs_Y (list) – Indexes defining each variable group.
rvs_Z (list) – Indexes defining each variable group.
order (float > 0) – The order
alpha.
- Returns:
I_a – Conditional Sibson mutual information in bits.
- Return type:
- sibson_conditional_mutual_information_z(dist, rvs_X, rvs_Y, rvs_Z, order)[source]
Conditional Sibson MI minimizing over
Q_Z(Esposito et al., Def. 4).Symmetric in
XandY.- Parameters:
dist (Distribution) – The joint distribution over
X,Y, andZ.rvs_X (list) – Indexes defining each variable group.
rvs_Y (list) – Indexes defining each variable group.
rvs_Z (list) – Indexes defining each variable group.
order (float > 0) – The order
alpha.
- Returns:
I_a – Conditional Sibson mutual information in bits.
- Return type:
- sibson_mutual_information(dist, rvs_X, rvs_Y, order)[source]
Compute the Sibson mutual information of order
order.This is asymmetric in
(X, Y):rvs_Xis the source variable whose marginal appears in the definition (Wu et al., Verdu).- Parameters:
dist (Distribution) – The joint distribution.
rvs_X (list) – Indexes of the random variables defining
X.rvs_Y (list) – Indexes of the random variables defining
Y.order (float > 0) – The order
alpha.
- Returns:
I_a – Sibson mutual information in bits.
- Return type:
- Raises:
ValueError – If
orderis not positive.
- sibson_mutual_information_pmf(p_xy, order)[source]
Compute the Sibson mutual information of order
order.- Parameters:
p_xy (array_like, shape (n_x, n_y)) – Joint PMF with axis 0 indexing
Xand axis 1 indexingY.order (float > 0) – The order
alpha. Use1for Shannon MI andnumpy.inffor maximal leakage.
- Returns:
I_a – Sibson mutual information in bits.
- Return type:
- Raises:
ValueError – If
orderis not positive.
- tsallis_entropy(dist, order, rvs=None)[source]
Compute the Tsallis entropy of order order.
- Parameters:
dist (Distribution) – The distribution to take the Tsallis entropy of.
order (float >= 0) – The order of the Tsallis entropy.
rvs (list, None) – The indexes of the random variable used to calculate the Tsallis entropy of. If None, then the Tsallis entropy is calculated over all random variables.
- Returns:
S_q – The Tsallis entropy.
- Return type:
- Raises:
ditException – Raised if rvs or crvs contain non-existant random variables.
ValueError – Raised if order is not a non-negative float.