infomeasure.estimators package#
Subpackages#
- infomeasure.estimators.entropy package
- Submodules
- infomeasure.estimators.entropy.ansb module
- infomeasure.estimators.entropy.bayes module
- infomeasure.estimators.entropy.bonachela module
- infomeasure.estimators.entropy.chao_shen module
- infomeasure.estimators.entropy.chao_wang_jost module
- infomeasure.estimators.entropy.discrete module
- infomeasure.estimators.entropy.grassberger module
- infomeasure.estimators.entropy.kernel module
- infomeasure.estimators.entropy.kozachenko_leonenko module
- infomeasure.estimators.entropy.miller_madow module
- infomeasure.estimators.entropy.nsb module
- infomeasure.estimators.entropy.ordinal module
- infomeasure.estimators.entropy.renyi module
- infomeasure.estimators.entropy.shrink module
- infomeasure.estimators.entropy.tsallis module
- infomeasure.estimators.entropy.zhang module
- Module contents
AnsbEntropyEstimatorBayesEntropyEstimatorBonachelaEntropyEstimatorChaoShenEntropyEstimatorChaoWangJostEntropyEstimatorDiscreteEntropyEstimatorGrassbergerEntropyEstimatorKernelEntropyEstimatorKozachenkoLeonenkoEntropyEstimatorMillerMadowEntropyEstimatorNsbEntropyEstimatorOrdinalEntropyEstimatorRenyiEntropyEstimatorShrinkEntropyEstimatorTsallisEntropyEstimatorZhangEntropyEstimator
- infomeasure.estimators.mutual_information package
- Submodules
- infomeasure.estimators.mutual_information.ansb module
- infomeasure.estimators.mutual_information.bayes module
- infomeasure.estimators.mutual_information.bonachela module
- infomeasure.estimators.mutual_information.chao_shen module
- infomeasure.estimators.mutual_information.chao_wang_jost module
- infomeasure.estimators.mutual_information.discrete module
- infomeasure.estimators.mutual_information.grassberger module
- infomeasure.estimators.mutual_information.kernel module
- infomeasure.estimators.mutual_information.kraskov_stoegbauer_grassberger module
- infomeasure.estimators.mutual_information.miller_madow module
- infomeasure.estimators.mutual_information.nsb module
- infomeasure.estimators.mutual_information.ordinal module
- infomeasure.estimators.mutual_information.renyi module
- infomeasure.estimators.mutual_information.shrink module
- infomeasure.estimators.mutual_information.tsallis module
- infomeasure.estimators.mutual_information.zhang module
- Module contents
AnsbCMIEstimatorAnsbMIEstimatorBayesCMIEstimatorBayesMIEstimatorBonachelaCMIEstimatorBonachelaMIEstimatorChaoShenCMIEstimatorChaoShenMIEstimatorChaoWangJostCMIEstimatorChaoWangJostMIEstimatorDiscreteCMIEstimatorDiscreteMIEstimatorGrassbergerCMIEstimatorGrassbergerMIEstimatorKSGCMIEstimatorKSGMIEstimatorKernelCMIEstimatorKernelMIEstimatorMillerMadowCMIEstimatorMillerMadowMIEstimatorNsbCMIEstimatorNsbMIEstimatorOrdinalCMIEstimatorOrdinalMIEstimatorRenyiCMIEstimatorRenyiMIEstimatorShrinkCMIEstimatorShrinkMIEstimatorTsallisCMIEstimatorTsallisMIEstimatorZhangCMIEstimatorZhangMIEstimator
- infomeasure.estimators.transfer_entropy package
- Submodules
- infomeasure.estimators.transfer_entropy.ansb module
- infomeasure.estimators.transfer_entropy.bayes module
- infomeasure.estimators.transfer_entropy.bonachela module
- infomeasure.estimators.transfer_entropy.chao_shen module
- infomeasure.estimators.transfer_entropy.chao_wang_jost module
- infomeasure.estimators.transfer_entropy.discrete module
- infomeasure.estimators.transfer_entropy.grassberger module
- infomeasure.estimators.transfer_entropy.kernel module
- infomeasure.estimators.transfer_entropy.kraskov_stoegbauer_grassberger module
- infomeasure.estimators.transfer_entropy.miller_madow module
- infomeasure.estimators.transfer_entropy.nsb module
- infomeasure.estimators.transfer_entropy.ordinal module
- infomeasure.estimators.transfer_entropy.renyi module
- infomeasure.estimators.transfer_entropy.shrink module
- infomeasure.estimators.transfer_entropy.tsallis module
- infomeasure.estimators.transfer_entropy.zhang module
- Module contents
AnsbCTEEstimatorAnsbTEEstimatorBayesCTEEstimatorBayesTEEstimatorBonachelaCTEEstimatorBonachelaTEEstimatorChaoShenCTEEstimatorChaoShenTEEstimatorChaoWangJostCTEEstimatorChaoWangJostTEEstimatorDiscreteCTEEstimatorDiscreteTEEstimatorGrassbergerCTEEstimatorGrassbergerTEEstimatorKSGCTEEstimatorKSGTEEstimatorKernelCTEEstimatorKernelTEEstimatorMillerMadowCTEEstimatorMillerMadowTEEstimatorNsbCTEEstimatorNsbTEEstimatorOrdinalCTEEstimatorOrdinalTEEstimatorRenyiCTEEstimatorRenyiTEEstimatorShrinkCTEEstimatorShrinkTEEstimatorTsallisCTEEstimatorTsallisTEEstimatorZhangCTEEstimatorZhangTEEstimator
- infomeasure.estimators.utils package
- Submodules
- infomeasure.estimators.utils.array module
- infomeasure.estimators.utils.discrete_interaction_information module
- infomeasure.estimators.utils.discrete_transfer_entropy module
- infomeasure.estimators.utils.exponential_family module
- infomeasure.estimators.utils.kde module
- infomeasure.estimators.utils.normalize module
- infomeasure.estimators.utils.ordinal module
- infomeasure.estimators.utils.te_slicing module
- infomeasure.estimators.utils.test_unit_ball_volume module
- infomeasure.estimators.utils.unit_ball_volume module
- Module contents
Submodules#
infomeasure.estimators.base module#
Module containing the base classes for the measure estimators.
- class infomeasure.estimators.base.ConditionalMutualInformationEstimator(*data, cond=None, normalize: bool = False, offset=None, base: int | float | str = 'e', **kwargs)[source]#
Bases:
StatisticalTestingMixin,Estimator[ConditionalMutualInformationEstimator],ABCAbstract base class for conditional mutual information estimators.
Conditional Mutual Information (CMI) between two (or more) random variables \(X\) and \(Y\) given a third variable \(Z\) quantifies the amount of information obtained about one variable through the other, conditioned on the third. In terms of entropy (H), CMI is expressed as:
\[I(X, Y | Z) = H(X, Z) + H(Y, Z) - H(X, Y, Z) - H(Z)\]where \(H(X, Z)\) is the joint entropy of \(X\) and \(Z\), \(H(Y, Z)\) is the joint entropy of \(Y\) and \(Z\), \(H(X, Y, Z)\) is the joint entropy of \(X\), \(Y\), and \(Z\), and \(H(Z)\) is the entropy of \(Z\).
- Attributes:
- *dataarray_like,
shape(n_samples,) The data used to estimate the conditional mutual information. You can pass an arbitrary number of data arrays as positional arguments.
- condarray_like
The conditional data used to estimate the conditional mutual information.
- normalizebool,
optional If True, normalize the data before analysis. Default is False.
- base
int|float| “e”,optional The logarithm base for the entropy calculation. The default can be set with
set_logarithmic_unit().
- *dataarray_like,
- Raises:
ValueErrorIf the data arrays have different lengths.
ValueErrorIf the data arrays are not of the same length.
ValueErrorIf normalization is requested for non-1D data.
- class infomeasure.estimators.base.ConditionalTransferEntropyEstimator(source, dest, *, cond=None, src_hist_len: int = 1, dest_hist_len: int = 1, cond_hist_len: int = 1, step_size: int = 1, prop_time=None, offset=None, base: int | float | str = 'e', **kwargs)[source]#
Bases:
EffectiveValueMixin,StatisticalTestingMixin,Estimator[ConditionalTransferEntropyEstimator],ABCAbstract base class for conditional transfer entropy estimators.
Conditional Transfer Entropy (CTE) from source \(X\) to destination \(Y\) given a condition \(Z\) quantifies the amount of information obtained about the destination variable through the source, conditioned on the condition.
- Attributes:
- sourcearray_like,
shape(n_samples,) The source data used to estimate the transfer entropy (X).
- destarray_like,
shape(n_samples,) The destination data used to estimate the transfer entropy (Y).
- condarray_like,
shape(n_samples,) The conditional data used to estimate the transfer entropy (Z).
- step_size
int Step size between elements for the state space reconstruction.
- src_hist_len, dest_hist_len, cond_hist_len
int Number of past observations to consider for the source, destination, and conditional data.
- prop_time
int,optional Not compatible with the conditional transfer entropy.
- base
int|float| “e”,optional The logarithm base for the entropy calculation. The default can be set with
set_logarithmic_unit().
- sourcearray_like,
- class infomeasure.estimators.base.DiscreteHEstimator(*args, **kwargs)[source]#
Bases:
EntropyEstimator,ABCAbstract base class for discrete entropy estimators.
The DiscreteHEstimator class is an abstract base class extending
EntropyEstimator. This class is specifically designed to handle entropy estimation for discrete variables. It ensures that input data is transformed into a format suitable for discrete entropy calculations, verifies input data validity, and reduces joint spaces where needed.It works exclusively with symbolized or discretized data, allowing entropy computations to remain accurate and efficient for discrete variables. The class also manages situations where multiple random variables’ joint data can be reduced to simplified forms for further statistical analysis. The data, after processing, is represented using unique values and counts instead of directly storing the original data.
- Attributes:
- data
tuple[DiscreteData] A tuple containing Discrete data objects. Each of them contains,
uniq,counts,N,K, and the originaldataarray. For normal and joint entropy len(data) = 1, for cross-entropy len(data) = 2.
- data
Methods
from_counts(uniq, counts[, base])Construct a DiscreteHEstimator from the provided counts.
from_probabilities(uniq, probabilities[, base])Construct a DiscreteHEstimator from the provided probabilities.
- class infomeasure.estimators.base.EntropyEstimator(*data, base: int | float | str = 'e')[source]#
Bases:
Estimator[EntropyEstimator],ABCAbstract base class for entropy estimators.
Estimates simple entropy of a data array or joint entropy of two data arrays.
- Attributes:
- *dataarray_like,
shape(n_samples,)ortupleofarray_like The data used to estimate the entropy. When passing a tuple of arrays, the joint entropy is considered. When passing two arrays, the cross-entropy is considered, the second RV relative to the first RV.
- base
int|float| “e”,optional The logarithm base for the entropy calculation. The default can be set with
set_logarithmic_unit().
- *dataarray_like,
Methods
Return the local values of the measure, if available.
- Raises:
ValueErrorIf the data is not an array or arrays tuple/list.
See also
Notes
Entropy: When passing one array-like object.
Joint Entropy: When passing one tuple of array-likes.
Cross-Entropy: When passing two array-like objects. Then the the second distribution \(q\) is considered relative to the first \(p\):
\(-\sum_{i=1}^{n} p_i \log_b q_i\)
- local_vals()[source]#
Return the local values of the measure, if available.
For cross-entropy, local values cannot be calculated.
- Returns:
- localarray_like
The local values of the measure.
- Raises:
io.UnsupportedOperationIf the local values are not available.
- class infomeasure.estimators.base.Estimator(base: int | float | str = 'e')[source]#
Bases:
Generic[EstimatorType],ABCAbstract base class for all measure estimators.
Find Estimator Usage on how to use the estimators and an overview of the available measures (Available approaches).
- Attributes:
- res_global
float|None The global value of the measure. None if the measure is not calculated.
- res_localarray_like |
None The local values of the measure. None if the measure is not calculated or if not defined.
- base
int|float| “e”,optional The logarithm base for the entropy calculation. The default can be set with
set_logarithmic_unit().
- res_global
Methods
Calculate the measure.
Return the global value of the measure.
Return the local values of the measure, if available.
result()Return the global value of the measure.
See also
EntropyEstimator,MutualInformationEstimator,TransferEntropyEstimator,DiscreteEntropyEstimator
Notes
The
_calculate()method needs to be implemented in the derived classes, for the local values or the global value. From local values, the global value is taken as the mean. If is to more efficient to directly calculate the global value, it is suggested to have_calculate()just return the global value, and have the separate_extract_local_values()method for the local values, which is lazily called bylocal_val(), if needed. If the measure has a p-value, thep_value()method should be implemented (useStatisticalTestingMixinfor standard implementations).- final calculate() None[source]#
Calculate the measure.
Estimate the measure and store the results in the attributes.
- final global_val() float[source]#
Return the global value of the measure.
Calculate the measure if not already calculated.
- Returns:
- global
float The global value of the measure.
- global
- local_vals()[source]#
Return the local values of the measure, if available.
- Returns:
- localarray_like
The local values of the measure.
- Raises:
io.UnsupportedOperationIf the local values are not available.
- class infomeasure.estimators.base.MutualInformationEstimator(*data, offset: int = 0, normalize: bool = False, base: int | float | str = 'e', **kwargs)[source]#
Bases:
StatisticalTestingMixin,Estimator[MutualInformationEstimator],ABCAbstract base class for mutual information estimators.
- Attributes:
- *dataarray_like,
shape(n_samples,) The data used to estimate the mutual information. You can pass an arbitrary number of data arrays as positional arguments.
- offset
int,optional If two data arrays are provided: Number of positions to shift the data arrays relative to each other. Delay/lag/shift between the variables. Default is no shift. Assumed time taken by info to transfer from X to Y.
- normalizebool,
optional If True, normalize the data before analysis. Default is False.
- base
int|float| “e”,optional The logarithm base for the entropy calculation. The default can be set with
set_logarithmic_unit().
- *dataarray_like,
- Raises:
ValueErrorIf the data arrays have different lengths.
ValueErrorIf the offset is not an integer.
ValueErrorIf offset is used with more than two data arrays.
- class infomeasure.estimators.base.TransferEntropyEstimator(source, dest, *, prop_time: int = 0, src_hist_len: int = 1, dest_hist_len: int = 1, step_size: int = 1, offset: int = None, base: int | float | str = 'e', **kwargs)[source]#
Bases:
EffectiveValueMixin,StatisticalTestingMixin,Estimator[TransferEntropyEstimator],ABCAbstract base class for transfer entropy estimators.
- Attributes:
- sourcearray_like,
shape(n_samples,) The source data used to estimate the transfer entropy (X).
- destarray_like,
shape(n_samples,) The destination data used to estimate the transfer entropy (Y).
- step_size
int Step size between elements for the state space reconstruction.
- src_hist_len, dest_hist_len
int Number of past observations to consider for the source and destination data.
- prop_time
int,optional Number of positions to shift the data arrays relative to each other (multiple of
step_size). Delay/lag/shift between the variables, representing propagation time. Default is no shift. Assumed time taken by info to transfer from source to destination.- base
int|float| “e”,optional The logarithm base for the entropy calculation. The default can be set with
set_logarithmic_unit().
- sourcearray_like,
- Raises:
ValueErrorIf the data arrays have different lengths.
ValueErrorIf the propagation time is not an integer.
infomeasure.estimators.functional module#
Functional wrappers for information estimators.
This module provides functional interfaces to calculate entropy, mutual information, and transfer entropy. The estimators are dynamically imported based on the estimator name provided, saving time and memory by only importing the necessary classes.
- infomeasure.estimators.functional.conditional_mutual_information(*data, **kwargs: any)[source]#
Conditional mutual information between two variables given a third variable.
See
mutual_informationfor more information.
- infomeasure.estimators.functional.conditional_transfer_entropy(*data, **kwargs: any)[source]#
Conditional transfer entropy between two variables given a third variable.
See
transfer_entropyfor more information.
- infomeasure.estimators.functional.cross_entropy(*data, **kwargs: any)[source]#
Calculate the cross-entropy using a functional interface of different estimators.
See
entropy()for more details on the parameters and returns.
- infomeasure.estimators.functional.entropy(*data, approach: str, **kwargs: any)[source]#
Calculate the (joint) entropy using a functional interface of different estimators.
Supports the following approaches:
bayes:Bayesian entropy estimator.bonachela:Bonachela entropy estimator.[
chao_shen,cs]:Chao-Shen entropy estimator.[
chao_wang_jost,cwj]:Chao Wang Jost entropy estimator.discrete:Discrete entropy estimator.grassberger:Grassberger entropy estimator.kernel:Kernel entropy estimator.[
metric,kl]:Kozachenko-Leonenko entropy estimator.[
miller_madow,mm]:Miller-Madow entropy estimator.[
ordinal,symbolic,permutation]:Ordinal / Permutation entropy estimator.renyi:Renyi entropy estimator.[
shrink,js]:Shrinkage (James-Stein) entropy estimator.tsallis:Tsallis entropy estimator.zhang:Zhang entropy estimator.
For the discrete Shannon entropy this is
\[\texttt{im.entropy(data_X, approach="discrete")} = H(X) = -\sum_{x \in X} p(x) \log p(x).\]Where for \(H(x)\), the estimated pmf \(p(x)\) belongs to the RV \(X\).
\[\texttt{im.entropy(data_P, data_Q, ...)} = H_Q(P) = H_\times(P, Q) = -\sum_{x \in X} p(x) \log q(x)\]For the cross-entropy \(H_Q(P)\), the estimated pmf \(p(x)\) belongs to the RV \(P\) and \(q(x)\) to the RV \(Q\). For other approaches, this formula is generalized in different forms.
- Parameters:
- *dataarray_like
The data used to estimate the entropy. For entropy, this can be an array-like. For joint entropy, pass the joint values inside a tuple. For cross-entropy, pass two separate parameters.
- approach
str The name of the estimator to use.
- **kwargs: dict
Additional keyword arguments to pass to the estimator.
- Returns:
floatThe calculated entropy.
- Raises:
ValueErrorIf the estimator is not recognised.
- infomeasure.estimators.functional.estimator(*data, cond=None, measure: str = None, approach: str = None, step_size: int = 1, prop_time: int = 0, src_hist_len: int = 1, dest_hist_len: int = 1, cond_hist_len: int = 1, **kwargs: any) EstimatorType[source]#
Get an estimator for a specific measure.
This function provides a simple interface to get an
Estimatorfor a specific measure.If you are only interested in the global result, use the functional interfaces:
Estimators available:
- Entropy:
bayes:Bayesian entropy estimator.bonachela:Bonachela entropy estimator.[
chao_shen,cs]:Chao-Shen entropy estimator.[
chao_wang_jost,cwj]:Chao Wang Jost entropy estimator.discrete:Discrete entropy estimator.grassberger:Grassberger entropy estimator.kernel:Kernel entropy estimator.[
metric,kl]:Kozachenko-Leonenko entropy estimator.[
miller_madow,mm]:Miller-Madow entropy estimator.[
ordinal,symbolic,permutation]:Ordinal / Permutation entropy estimator.renyi:Renyi entropy estimator.[
shrink,js]:Shrinkage (James-Stein) entropy estimator.tsallis:Tsallis entropy estimator.zhang:Zhang entropy estimator.
- Mutual Information:
bonachela:Bonachela mutual information estimator.chao_shen:Chao-Shen mutual information estimator.chao_wang_jost:Chao Wang Jost mutual information estimator.discrete:Discrete mutual information estimator.grassberger:Grassberger mutual information estimator.[
metric,ksg]:Kraskov-Stoegbauer-Grassberger mutual information estimator.[
miller_madow,mm]:Miller-Madow mutual information estimator.nsb:NSB (Nemenman-Shafee-Bialek) mutual information estimator.[
ordinal,symbolic,permutation]:Ordinal mutual information estimator.shrink:Shrinkage (James-Stein) mutual information estimator.
- Transfer Entropy:
bonachela:Bonachela transfer entropy estimator.chao_shen:Chao-Shen transfer entropy estimator.chao_wang_jost:Chao Wang Jost transfer entropy estimator.discrete:Discrete transfer entropy estimator.grassberger:Grassberger transfer entropy estimator.[
metric,ksg]:Kraskov-Stoegbauer-Grassberger transfer entropy estimator.[
miller_madow,mm]:Miller-Madow transfer entropy estimator.nsb:NSB (Nemenman-Shafee-Bialek) transfer entropy estimator.[
ordinal,symbolic,permutation]:Ordinal transfer entropy estimator.tsallis:Tsallis transfer entropy estimator.
- Parameters:
- *data
The data used to estimate the measure. For entropy: a single array-like data. A tuple of data for joint entropy. For cross-entropy: two array-like data. Second input RV relative to the first. For mutual information: arbitrary number of array-like data. For transfer entropy: two array-like data. Source and destination.
- condarray_like,
optional Only if the measure is conditional transfer entropy.
- measure
str The measure to estimate. Options:
entropy,cross_entropy,mutual_information,transfer_entropy,conditional_mutual_information,conditional_transfer_entropy; aliases:h,hx,mi,te,cmi,cte.- approach
str The name of the estimator to use. Find the available estimators in the docstring of this function.
- *args: tuple
Additional arguments to pass to the estimator.
- **kwargs: dict
Additional keyword arguments to pass to the estimator.
- Returns:
EstimatorThe estimator instance.
- Raises:
ValueErrorIf the measure is not recognised.
- infomeasure.estimators.functional.get_estimator_class(measure=None, approach=None) EstimatorType[source]#
Get estimator class based on the estimator name and approach.
This function returns the estimator class based on the measure and approach provided. If you want an instance of an estimator, initialized with data and parameters, use the functional interface
estimator().- Parameters:
- Returns:
classThe estimator class.
- Raises:
ValueErrorIf the measure is not recognized.
ValueErrorIf the approach is not recognized.
- infomeasure.estimators.functional.mutual_information(*data, approach: str, **kwargs: any)[source]#
Calculate the mutual information using a functional interface of different estimators.
Supports the following approaches:
bonachela:Bonachela mutual information estimator.chao_shen:Chao-Shen mutual information estimator.chao_wang_jost:Chao Wang Jost mutual information estimator.discrete:Discrete mutual information estimator.grassberger:Grassberger mutual information estimator.[
metric,ksg]:Kraskov-Stoegbauer-Grassberger mutual information estimator.[
miller_madow,mm]:Miller-Madow mutual information estimator.nsb:NSB (Nemenman-Shafee-Bialek) mutual information estimator.[
ordinal,symbolic,permutation]:Ordinal mutual information estimator.shrink:Shrinkage (James-Stein) mutual information estimator.
- Parameters:
- *dataarray_like
The data used to estimate the (conditional) mutual information.
- condarray_like,
optional The conditional data used to estimate the conditional mutual information.
- approach
str The name of the estimator to use.
- normalizebool,
optional If True, normalize the data before analysis. Default is False. Not available for the discrete estimator.
- **kwargs: dict
Additional keyword arguments to pass to the estimator.
- Returns:
floatThe calculated mutual information.
- Raises:
ValueErrorIf the estimator is not recognised.
- infomeasure.estimators.functional.transfer_entropy(*data, approach: str, **kwargs: any)[source]#
Calculate the transfer entropy using a functional interface of different estimators.
Supports the following approaches:
bonachela:Bonachela transfer entropy estimator.chao_shen:Chao-Shen transfer entropy estimator.chao_wang_jost:Chao Wang Jost transfer entropy estimator.discrete:Discrete transfer entropy estimator.grassberger:Grassberger transfer entropy estimator.[
metric,ksg]:Kraskov-Stoegbauer-Grassberger transfer entropy estimator.[
miller_madow,mm]:Miller-Madow transfer entropy estimator.nsb:NSB (Nemenman-Shafee-Bialek) transfer entropy estimator.[
ordinal,symbolic,permutation]:Ordinal transfer entropy estimator.tsallis:Tsallis transfer entropy estimator.
- Parameters:
- source, destarray_like
The source (X) and destination (Y) data used to estimate the transfer entropy.
- condarray_like,
optional The conditional data used to estimate the conditional transfer entropy.
- approach
str The name of the estimator to use.
- step_size
int Step size between elements for the state space reconstruction.
- src_hist_len, dest_hist_len
int Number of past observations to consider for the source and destination data.
- prop_time
int,optional Number of positions to shift the data arrays relative to each other. Delay/lag/shift between the variables. Default is no shift. Assumed time taken by info to transfer from source to destination. Not compatible with the
condparameter / conditional TE. Alternatively calledoffset.- *args: tuple
Additional arguments to pass to the estimator.
- **kwargs: dict
Additional keyword arguments to pass to the estimator.
- Returns:
floatThe calculated transfer entropy.
- Raises:
ValueErrorIf the estimator is not recognised.
infomeasure.estimators.mixins module#
Mixin classes for estimators from .base.py.
- class infomeasure.estimators.mixins.DiscreteMIMixin(*args, **kwargs)[source]#
Bases:
objectMixin for handling discrete mutual information computations.
Provides utilities and checks necessary for estimating discrete mutual information and conditional mutual information. Ensures that input data is suitable for these calculations and provides warnings when pre-processing steps, such as symbolizing or discretizing, are required.
- Attributes:
- data
Any The primary data to be used in mutual information estimation. It should be symbolized or discretized if it contains floating-point types.
- cond
Any,optional The conditional data for conditional mutual information estimation. If provided, it should also be symbolized or discretized if it contains floating-point types.
- data
- class infomeasure.estimators.mixins.DiscreteTEMixin[source]#
Bases:
objectMixin class for discrete transfer entropy calculations.
Provides functionality to validate input data types for transfer entropy estimation processes. Ensures that source, destination, and conditional datasets are properly symbolized or discretized to prevent invalid results from using continuous floating-point data.
- Attributes:
- sourcearray_like
The source data array utilized in transfer entropy calculations.
- destarray_like
The destination data array utilized in transfer entropy calculations.
- condarray_like,
optional The conditional data array utilized in transfer entropy calculations when applicable.
- class infomeasure.estimators.mixins.EffectiveValueMixin(*args, **kwargs)[source]#
Bases:
StatisticalTestingMixinMixin for effective value calculation.
To be used as a mixin class with
TransferEntropyEstimatorderived classes. Inherit before the main class.Methods
effective_val([method])Return the effective value.
Notes
The effective value is the difference between the original value and the value calculated for the permuted data.
- class infomeasure.estimators.mixins.RandomGeneratorMixin(*args, seed=None, **kwargs)[source]#
Bases:
objectMixin for random state generation.
- Attributes:
- rng
Generator The random state generator.
- rng
- class infomeasure.estimators.mixins.StatisticalTestingMixin(*args, **kwargs)[source]#
Bases:
RandomGeneratorMixinMixin for comprehensive statistical testing including p-values, t-scores, and confidence intervals.
There are two methods to perform statistical tests:
Permutation test: shuffle the data and calculate the measure.
Bootstrap: resample the data and calculate the measure.
The
statistical_test()method provides comprehensive statistical analysis including p-value, t-score, and confidence intervals in a single call.To be used as a mixin class with other
EstimatorEstimator classes. Inherit before the main class.Methods
statistical_test([n_tests, method])Perform comprehensive statistical test including p-value, t-score, and confidence intervals.
- Raises:
NotImplementedErrorIf the statistical test is not implemented for the estimator.
Notes
The permutation test is a non-parametric statistical test to determine if the observed effect is significant. The null hypothesis is that the measure is not different from random, and the p-value is the proportion of permuted measures greater than the observed measure.
Confidence intervals are calculated using percentiles of the null distribution from the resampling procedure.
- statistical_test(n_tests: int = None, method: str = None) StatisticalTestResult[source]#
Perform comprehensive statistical test including p-value, t-score, and confidence intervals.
Method can be “permutation_test” or “bootstrap”.
Permutation test: shuffle the data and calculate the measure.
Bootstrap: resample the data and calculate the measure.
- Parameters:
- n_tests
int,optional Number of permutations or bootstrap samples. Needs to be a positive integer. Default is the value set in the configuration.
- method
str,optional The method to calculate the statistical test. Options are “permutation_test” or “bootstrap”. Default is the value set in the configuration.
- n_tests
- Returns:
StatisticalTestResultComprehensive statistical test result containing p-value, t-score, and metadata. Percentiles can be calculated on demand using the percentile() method.
- Raises:
ValueErrorIf the chosen method is unknown.
io.UnsupportedOperationIf the statistical test is not supported for the estimator type.
Module contents#
Measures module for infomeasure package.