infomeasure.estimators.entropy package#
Submodules#
infomeasure.estimators.entropy.discrete module#
Module for the discrete entropy estimator.
- class infomeasure.estimators.entropy.discrete.DiscreteEntropyEstimator(data, *, base: int | float | str = 'e')[source]#
Bases:
DistributionMixin,EntropyEstimatorEstimator for discrete entropy (Shannon entropy).
- Attributes:
- dataarray_like
The data used to estimate the entropy.
infomeasure.estimators.entropy.kernel module#
Module for the kernel entropy estimator.
- class infomeasure.estimators.entropy.kernel.KernelEntropyEstimator(data, *, bandwidth: float | int, kernel: str, workers: int = 1, base: int | float | str = 'e')[source]#
Bases:
WorkersMixin,EntropyEstimatorEstimator for entropy (Shannon) using Kernel Density Estimation (KDE).
- Attributes:
- dataarray_like
The data used to estimate the entropy.
- bandwidth
float|int The bandwidth for the kernel.
- kernel
str Type of kernel to use, compatible with the KDE implementation
kde_probability_density_function().- workers
int,optional Number of workers to use for parallel processing. Default is 1, meaning no parallel processing. If set to -1, all available CPU cores will be used.
Notes
A small
bandwidthcan lead to under-sampling, while a largebandwidthmay over-smooth the data, obscuring details.
infomeasure.estimators.entropy.kozachenko_leonenko module#
Module for the Kozacenko-Leonenko entropy estimator.
- class infomeasure.estimators.entropy.kozachenko_leonenko.KozachenkoLeonenkoEntropyEstimator(data, *, k: int = 4, noise_level=1e-10, minkowski_p=inf, base: int | float | str = 'e')[source]#
Bases:
RandomGeneratorMixin,EntropyEstimatorKozachenko-Leonenko estimator for Shannon entropies.
- Attributes:
- dataarray_like
The data used to estimate the entropy.
- k
int The number of nearest neighbors to consider.
- noise_level
float The standard deviation of the Gaussian noise to add to the data to avoid issues with zero distances.
- minkowski_p
float, \(1 \leq p \leq \infty\) The power parameter for the Minkowski metric. Default is np.inf for maximum norm. Use 2 for Euclidean distance.
- Raises:
ValueErrorIf the number of nearest neighbors is not a positive integer
ValueErrorIf the noise level is negative
ValueErrorIf the Minkowski power parameter is invalid
Notes
Changing the number of nearest neighbors
kcan change the outcome, but the default value of \(k=4\) is recommended by [KStogbauerG11].
infomeasure.estimators.entropy.ordinal module#
Module for the Ordinal / Permutation entropy estimator.
- class infomeasure.estimators.entropy.ordinal.OrdinalEntropyEstimator(data, *, embedding_dim: int, stable: bool = False, base: int | float | str = 'e')[source]#
Bases:
DistributionMixin,EntropyEstimatorEstimator for the Ordinal / Permutation entropy.
The Ordinal entropy is a measure of the complexity of a time series. The input data needs to be comparable, i.e., the data should be ordinal, as the relative frequencies are calculated. For a given
embedding_dim(length of considered subsequences), all \(n!\) possible permutations are considered and their relative frequencies are calculated [BP02].Embedding delay is not supported natively.
- Attributes:
- dataarray_like
The data used to estimate the entropy.
- embedding_dim
int The size of the permutation patterns.
- stablebool,
optional If True, when sorting the data, the embedding_dim of equal elements is preserved. This can be useful for reproducibility and testing, but might be slower.
- Raises:
ValueErrorIf the
embedding_dimis negative or not an integer.ValueErrorIf the
embedding_dimis too large for the given data.TypeErrorIf the data are not 1d array-like(s).
Notes
The ordinality will be determined via
numpy.argsort().If
embedding_dimis set to 1, the entropy is always 0.
infomeasure.estimators.entropy.renyi module#
Module for the Rényi entropy estimator.
- class infomeasure.estimators.entropy.renyi.RenyiEntropyEstimator(data, *, k: int = 4, alpha: float | int = None, base: int | float | str = 'e')[source]#
Bases:
EntropyEstimatorEstimator for the Rényi entropy.
- Attributes:
- dataarray_like
The data used to estimate the entropy.
- k
int The number of nearest neighbors used in the estimation.
- alpha
float|int The Rényi parameter, order or exponent. Sometimes denoted as \(\alpha\) or \(q\).
- Raises:
ValueErrorIf the Renyi parameter is not a positive number.
ValueErrorIf the number of nearest neighbors is not a positive integer.
Notes
The Rényi entropy is a generalization of Shannon entropy, where the small values of probabilities are emphasized for \(\alpha < 1\), and higher probabilities are emphasized for \(\alpha > 1\). For \(\alpha = 1\), it reduces to Shannon entropy. The Rényi-Entropy class can be particularly interesting for systems where additivity (in Shannon sense) is not always preserved, especially in nonlinear complex systems, such as when dealing with long-range forces.
infomeasure.estimators.entropy.tsallis module#
Module for Tsallis entropy estimator.
- class infomeasure.estimators.entropy.tsallis.TsallisEntropyEstimator(data, *, k: int = 4, q: float | int = None, base: int | float | str = 'e')[source]#
Bases:
EntropyEstimatorEstimator for the Tsallis entropy.
- Attributes:
- dataarray_like
The data used to estimate the entropy.
- k
int The number of nearest neighbors used in the estimation.
- q
float The Tsallis parameter, order or exponent. Sometimes denoted as \(q\), analogous to the Rényi parameter \(\alpha\).
- Raises:
ValueErrorIf the Tsallis parameter is not a positive number.
ValueErrorIf the number of nearest neighbors is not a positive integer.
Notes
In the \(q \to 1\) limit, the Jackson sum (q-additivity) reduces to ordinary summation, and the Tallis entropy reduces to Shannon Entropy. This class of entropy measure is in particularly useful in the study in connection with long-range correlated systems and with non-equilibrium phenomena.
Module contents#
Entropy estimators.
- class infomeasure.estimators.entropy.DiscreteEntropyEstimator(data, *, base: int | float | str = 'e')[source]#
Bases:
DistributionMixin,EntropyEstimatorEstimator for discrete entropy (Shannon entropy).
- Attributes:
- dataarray_like
The data used to estimate the entropy.
- class infomeasure.estimators.entropy.KernelEntropyEstimator(data, *, bandwidth: float | int, kernel: str, workers: int = 1, base: int | float | str = 'e')[source]#
Bases:
WorkersMixin,EntropyEstimatorEstimator for entropy (Shannon) using Kernel Density Estimation (KDE).
- Attributes:
- dataarray_like
The data used to estimate the entropy.
- bandwidth
float|int The bandwidth for the kernel.
- kernel
str Type of kernel to use, compatible with the KDE implementation
kde_probability_density_function().- workers
int,optional Number of workers to use for parallel processing. Default is 1, meaning no parallel processing. If set to -1, all available CPU cores will be used.
Notes
A small
bandwidthcan lead to under-sampling, while a largebandwidthmay over-smooth the data, obscuring details.
- class infomeasure.estimators.entropy.KozachenkoLeonenkoEntropyEstimator(data, *, k: int = 4, noise_level=1e-10, minkowski_p=inf, base: int | float | str = 'e')[source]#
Bases:
RandomGeneratorMixin,EntropyEstimatorKozachenko-Leonenko estimator for Shannon entropies.
- Attributes:
- dataarray_like
The data used to estimate the entropy.
- k
int The number of nearest neighbors to consider.
- noise_level
float The standard deviation of the Gaussian noise to add to the data to avoid issues with zero distances.
- minkowski_p
float, \(1 \leq p \leq \infty\) The power parameter for the Minkowski metric. Default is np.inf for maximum norm. Use 2 for Euclidean distance.
- Raises:
ValueErrorIf the number of nearest neighbors is not a positive integer
ValueErrorIf the noise level is negative
ValueErrorIf the Minkowski power parameter is invalid
Notes
Changing the number of nearest neighbors
kcan change the outcome, but the default value of \(k=4\) is recommended by [KStogbauerG11].
- class infomeasure.estimators.entropy.OrdinalEntropyEstimator(data, *, embedding_dim: int, stable: bool = False, base: int | float | str = 'e')[source]#
Bases:
DistributionMixin,EntropyEstimatorEstimator for the Ordinal / Permutation entropy.
The Ordinal entropy is a measure of the complexity of a time series. The input data needs to be comparable, i.e., the data should be ordinal, as the relative frequencies are calculated. For a given
embedding_dim(length of considered subsequences), all \(n!\) possible permutations are considered and their relative frequencies are calculated [BP02].Embedding delay is not supported natively.
- Attributes:
- dataarray_like
The data used to estimate the entropy.
- embedding_dim
int The size of the permutation patterns.
- stablebool,
optional If True, when sorting the data, the embedding_dim of equal elements is preserved. This can be useful for reproducibility and testing, but might be slower.
- Raises:
ValueErrorIf the
embedding_dimis negative or not an integer.ValueErrorIf the
embedding_dimis too large for the given data.TypeErrorIf the data are not 1d array-like(s).
Notes
The ordinality will be determined via
numpy.argsort().If
embedding_dimis set to 1, the entropy is always 0.
- class infomeasure.estimators.entropy.RenyiEntropyEstimator(data, *, k: int = 4, alpha: float | int = None, base: int | float | str = 'e')[source]#
Bases:
EntropyEstimatorEstimator for the Rényi entropy.
- Attributes:
- dataarray_like
The data used to estimate the entropy.
- k
int The number of nearest neighbors used in the estimation.
- alpha
float|int The Rényi parameter, order or exponent. Sometimes denoted as \(\alpha\) or \(q\).
- Raises:
ValueErrorIf the Renyi parameter is not a positive number.
ValueErrorIf the number of nearest neighbors is not a positive integer.
Notes
The Rényi entropy is a generalization of Shannon entropy, where the small values of probabilities are emphasized for \(\alpha < 1\), and higher probabilities are emphasized for \(\alpha > 1\). For \(\alpha = 1\), it reduces to Shannon entropy. The Rényi-Entropy class can be particularly interesting for systems where additivity (in Shannon sense) is not always preserved, especially in nonlinear complex systems, such as when dealing with long-range forces.
- class infomeasure.estimators.entropy.TsallisEntropyEstimator(data, *, k: int = 4, q: float | int = None, base: int | float | str = 'e')[source]#
Bases:
EntropyEstimatorEstimator for the Tsallis entropy.
- Attributes:
- dataarray_like
The data used to estimate the entropy.
- k
int The number of nearest neighbors used in the estimation.
- q
float The Tsallis parameter, order or exponent. Sometimes denoted as \(q\), analogous to the Rényi parameter \(\alpha\).
- Raises:
ValueErrorIf the Tsallis parameter is not a positive number.
ValueErrorIf the number of nearest neighbors is not a positive integer.
Notes
In the \(q \to 1\) limit, the Jackson sum (q-additivity) reduces to ordinary summation, and the Tallis entropy reduces to Shannon Entropy. This class of entropy measure is in particularly useful in the study in connection with long-range correlated systems and with non-equilibrium phenomena.