Mutual Information#
Mutual Information (MI) measures the amount of information obtained about one random variable through observing another random variable.
import delaynet as dn
# Calculate mutual information
result = dn.connectivity(
ts1, ts2, metric="mutual_information", approach="kernel", lag_steps=5
)
or more involved with ordinal mutual information
import delaynet as dn
# Calculate transfer entropy
result = dn.connectivity(
ts1,
ts2,
metric="mutual_information",
approach='ordinal',
lag_steps=5,
embedding_dim=3
)
Parameters:
approach: The approach to use for estimating mutual information. For available approaches, find the string ininfomeasure.mutual_information().lag_steps: Time lags to consider. An integer will consider lags [1, …, lag_steps]. Passing a list will consider the specified values as lags.hypothesis_type: Type of hypothesis test to use (‘permutation_test’ or ‘bootstrap’). Default is ‘permutation_test’.n_tests: Number of iterations or resamples to perform within the hypothesis test. Default is 20.Additional keyword arguments are passed directly to the mutual information estimator.
- connectivities.mutual_information(ts2, approach: str = '', lag_steps: int | list = None, hypothesis_type: str = 'permutation_test', n_tests: int = 20, **mi_kwargs)
Mutual Information (MI) connectivity metric [ButhAZ25].
- Parameters:
ts1 (numpy.ndarray) – First time series.
ts2 (numpy.ndarray) – Second time series.
approach (str) – Approach to use. See
infomeasure.mutual_information()for available approaches.lag_steps (int | list) – Time lags to consider. Can be a single integer or a list of integers. An integer will consider lags [1, …, lag_steps]. A list will consider the specified values as lags.
hypothesis_type (str) – Type of hypothesis test to use. Either ‘permutation_test’ or ‘bootstrap’. Default is ‘permutation_test’.
n_tests (int) – Number of iterations or resamples to perform within the hypothesis test.
mi_kwargs – Additional keyword arguments for the mutual information estimator.
- Returns:
Best p-value and corresponding lag.
- Return type:
- Raises:
ValueError – If
approachis not given.