dyconnmap.ts package¶
Submodules¶
dyconnmap.ts.ci module¶
Complexity Index
Complexity index (Janson2004, Rapp2007) computes the l-subword complexity (l-subword spectrum) of a one-dimensional, symbolic (integer) time series, by finding the number of distinct subwords of length l. The total complexity is given by the sum of all subwords of different lengths. The unnormalized measure can be used to compare sequences of equal lengths.
Notes
This is a direct translation from the Complexity toolbox available at http://users.auth.gr/~stdimitr/files/software/complexitiy.rar
Original author is Stravros Dimitriadis <stidimitriadis@gmail.com>
- Janson2004
Janson, S., Lonardi, S., & Szpankowski, W. (2004). On average sequence complexity. Theoretical Computer Science, 326(1-3), 213-227.
- Rapp2007
Rapp, P. E. (2007). Quantitative characterization of animal behavior following blast exposure. Cognitive neurodynamics, 1(4), 287-293.
-
dyconnmap.ts.ci.
complexity_index
(x: np.ndarray[np.int32], sub_len: Optional[int] = - 1, normalize: Optional[bool] = False, iterations: Optional[int] = 100) → Union[Tuple[numpy.float32, np.ndarray[np.int32]], Tuple[numpy.float32, numpy.float32, np.ndarray[np.int32]]][source]¶ Complexity Index
- Parameters
x (array-like, shape(n_samples)) – Input symbolic time series.
sub_len (int) – Maximum subword length. Default is len(x) - 1.
normalize (bool) – Normalize result. Default is False.
iterationss (int) – Number of iterations to perform randomization. Default is 100.
- Returns
normal_ci (float) – The computed omplexity index after normalization against the randomization procedure.
ci (float) – The computed complexity index.
spectrum (array-like) – A list of the number of distinct subwords of length 1, up to the size of the input symbolic time series.
dyconnmap.ts.cv module¶
Coefficient of Variation
dyconnmap.ts.dcorr module¶
Distance Correlation
Notes
Snippet adapted from: https://gist.github.com/Satra/aa3d19a12b74e9ab7941
dyconnmap.ts.embed_delay module¶
When dealing with non-linear time series analysis, it is common to reconstruct hem as time delay vectors in phase space. This new reconstruction, describes the tmporal evolution of a system in a state space; a trajectory of interchanging states. The need for this state space, stems from the fact that the original system may contain latent and unobserved variables that we would like to expose. Thus, we construct \(m\)-dimensional phase vectors from \(\tau\)-time delayed samples (Takens1981_):
This new space, is shown to preserve the dynamics properties of the original phase space. For more on the subject, the interested readers are encouraged to consult the work of Bradley and Kantz (Bradley2015).
- Taken1981
Takens, F. (1981). Detecting strange attractors in turbulence. Lecture notes in mathematics, 898(1), 366-381.
- Bradley2015
Bradley, E., & Kantz, H. (2015). Nonlinear time-series analysis revisited. Chaos: An Interdisciplinary Journal of Nonlinear Science, 25(9), 097610.
-
dyconnmap.ts.embed_delay.
embed_delay
(ts: np.ndarray[np.float32], dim: int, tau: int) → Optional[np.ndarray[np.float32]][source]¶ Embed delay
- Parameters
ts (array-like, shape(n_samples)) – One-dimensional symbolic time series.
dim (int) – The embedding dimension.
tau (int) – Time delay factor.
- Returns
y – The embedded timeseries.
- Return type
array-like
dyconnmap.ts.entropy module¶
Entropy
dyconnmap.ts.fisher_score module¶
Fisher Scoring Algorithm
- Stam2007
Stam, C. J., Nolte, G., & Daffertshofer, A. (2007). Phase lag index: assessment of functional connectivity from multi channel EEG and MEG with diminished bias from common sources. Human brain mapping, 28(11), 1178-1193.
- Hardmeier2014
Hardmeier, M., Hatz, F., Bousleiman, H., Schindler, C., Stam, C. J., & Fuhr, P. (2014). Reproducibility of functional connectivity and graph measures based on the phase lag index (PLI) and weighted phase lag index (wPLI) derived from high resolution EEG. PloS one, 9(10), e108648.
dyconnmap.ts.fisher_z module¶
Fisher’s Z Transformation
- Stam2007
Stam, C. J., Nolte, G., & Daffertshofer, A. (2007). Phase lag index: assessment of functional connectivity from multi channel EEG and MEG with diminished bias from common sources. Human brain mapping, 28(11), 1178-1193.
- Hardmeier2014
Hardmeier, M., Hatz, F., Bousleiman, H., Schindler, C., Stam, C. J., & Fuhr, P. (2014). Reproducibility of functional connectivity and graph measures based on the phase lag index (PLI) and weighted phase lag index (wPLI) derived from high resolution EEG. PloS one, 9(10), e108648.
-
dyconnmap.ts.fisher_z.
fisher_z
(data)[source]¶ Fisher’s z-transformation
For a given dataset \(p\) bound to \([0.0, 1.0]\), we can use Fisher’s z-transformation to normalize it in an approximately Gaussian distribution.
This transformation is computed as follows:
\[z_p := \frac{1}{2} \text{ln} \left ( \frac{1+p}{1-p} \right ) = \text{arctanh}(p)\]- Parameters
data –
-
dyconnmap.ts.fisher_z.
fisher_z_plv
(data)[source]¶ - \[z^p_j = sin^{-1}(2 * PLV_j - 1)\]
- Returns
|
—–
.. [Mormann2005] Mormann, F., Fell, J., Axmacher, N., Weber, B., Lehnertz, K., Elger, C. E., & Fernández, G. (2005). Phase/amplitude reset and theta–gamma interaction in the human medial temporal lobe during a continuous word recognition memory task. Hippocampus, 15(7), 890-900.
dyconnmap.ts.fnn module¶
False Nearest Neighbors
- Kennel1992
Kennel, M. B., Brown, R., & Abarbanel, H. D. (1992). Determining embedding dimension for phase-space reconstruction using a geometrical construction. Physical review A, 45(6), 3403.
- Abarbane2012
Abarbanel, H. (2012). Analysis of observed chaotic data. Springer Science & Business Media.
-
dyconnmap.ts.fnn.
fnn
(ts: np.ndarray[np.float32], tau: int, max_dim: Optional[int] = 20, neighbors_reduction: Optional[float] = 0.1, rtol: Optional[float] = 15.0, atol: Optional[float] = 2.0) → Optional[int][source]¶ False Nearest Neighbors
Notes
The execution stops either when the maxium number of embedding dimensions is reached, or the the number of neighbors is reduced to specific percentage.
- Parameters
ts (array-like, 1d) –
tau (int) – Time-delay parameter.
max_dim (int) – Maximum embedding dimension.
neighbors_reduction (float) – Maximum percentage of neighbors reduction. Default ‘0.10’ (10%).
rtol (float) – First threshold, criterion to identify a false neighbor. (Neighborhood size)
atol (float) – Second threshold, criterion to identify a false neighbor.
- Returns
min_dimension – Minimum embedding dimension.
- Return type
int
dyconnmap.ts.icc module¶
Intra-class Correlation (3, 1)
Notes
Based on the code available at <https://github.com/ekmolloy/fmri_test-retest>
- McGraw1996
McGraw, K. O., & Wong, S. P. (1996). Forming inferences about some intraclass correlation coefficients. Psychological methods, 1(1), 30.
- Birn2013
Birn, R. M., Molloy, E. K., Patriat, R., Parker, T., Meier, T. B., Kirk, G. R., … & Prabhakaran, V. (2013). The effect of scan length on the reliability of resting-state fMRI connectivity estimates. Neuroimage, 83, 550-558.
dyconnmap.ts.markov_matrix module¶
Markov matrix
Generation of markov matrix and some related state transition features.
-
dyconnmap.ts.markov_matrix.
markov_matrix
(symts: np.ndarray[np.int32], states_from_length: Optional[bool] = True) → np.ndarray[np.float32][source]¶ Markov Matrix
Markov matrix (also refered as “transition matrix”) is a square matrix that tabulates the observed transition probabilities between symbols for a finite Markov Chain. It is a first-order descriptor by which the next symbol depends only on the current symbol (and not on the previous ones); a Markov Chain model.
A transition matrix is formally depicted as:
Given the probability \(Pr(j|i)\) of moving between \(i\) and \(j\) elements, the transition matrix is depicted as:
\[\begin{split}P = \begin{pmatrix} P_{1,1} & P_{1,2} & \ldots & P_{1,j} & \ldots & P_{1,S} \\ P_{2,1} & P_{2,2} & \ldots & P_{2,j} & \ldots & P_{2,S} \\ \vdots & \vdots & \ddots & \vdots & \ddots & \vdots \\ P_{i,1} & P_{i,2} & \ldots & P_{i,j} & \ldots & P_{i,S} \\ \vdots & \vdots & \ddots & \vdots & \ddots & \vdots \\ P_{S,1} & P_{S,2} & \ldots & P_{S,j} & \ldots & P_{S,S} \\ \end{pmatrix}\end{split}\]Since the transition matrix is row-normalized, so as the total transition probability from state \(i\) to all the others must be equal to \(1\).
For more properties consult, among other links WolframMathWorld_ and WikipediaMarkovMatrix_.
- WolframMathWorld
- WikipediaMarkovMatrix
- Parameters
symts (array-like, shape(N)) – One-dimensional discrete time series.
states_from_length (bool or int, optional) – Used to account symbolic time series in which not all the symbols are present. That may happen when for example the symbols are drawn from different distributions. Default True, the size of the resulting Markov Matrix is equal to the number of unique symbols present in the time series. If False, the size will be the highest symbolic state + 1. You may also speficy the highest (inclusive) symbolic state.
- Returns
mtx – The transition matrix. The size depends the parameter states_from_length.
- Return type
matrix
-
dyconnmap.ts.markov_matrix.
occupancy_time
(symts: np.ndarray[np.int32], symbol_states: numpy.int32 = None, weight: Optional[Union[numpy.float32, np.ndarray[np.float32]]] = None) → Tuple[numpy.float64, np.ndarray[np.int32]][source]¶ Occupancy Time
- Parameters
symts –
symbol_states (int) – The maximum number of symbols. This is useful to define in case your symbolic timeseries skips some states, in which case would produce a matrix of different size.
weight (float) – The weights of the reuslting transition symbols. Default len(symts).
- Returns
oc
symbols
dyconnmap.ts.ordinal_pattern_similarity module¶
Ordinal Pattern Similarity
- Stam2007
Stam, C. J., Nolte, G., & Daffertshofer, A. (2007). Phase lag index: assessment of functional connectivity from multi channel EEG and MEG with diminished bias from common sources. Human brain mapping, 28(11), 1178-1193.
- Hardmeier2014
Hardmeier, M., Hatz, F., Bousleiman, H., Schindler, C., Stam, C. J., & Fuhr, P. (2014). Reproducibility of functional connectivity and graph measures based on the phase lag index (PLI) and weighted phase lag index (wPLI) derived from high resolution EEG. PloS one, 9(10), e108648.
-
dyconnmap.ts.ordinal_pattern_similarity.
ordinal_pattern_similarity
(signal1: np.ndarray[np.int32], signal2: np.ndarray[np.int32], m: int, tau: int) → Tuple[float, np.ndarray[np.int32], np.ndarray[np.float32]][source]¶ Ordinal Pattern Similarity
- Parameters
signal1 –
signal2 –
m (int) – Embedding dimension.
tau (int) – Time delay parameter.
Notes
The results may vary from the original MATLAB script because of the permutations’ order.
The permutations are generated from \([1, dim+1]\) so there are no occurances of \(0.\)
The extra \(+1\) in the lines .. python: I = sklearn.preprocessing.normalize(I + 1) is in order to avoid :math:`0`s.
- Returns
dissimilarity (float) – The dissimilarity index as computed from the ordinal patterns.
ordinal_patterns (array) – The time series of ordinal patterns for input signals.
patterns_distribution (array) – Distribution of the patterns.
dyconnmap.ts.permutation_entropy module¶
Permutation Entropy
- Stam2007
Stam, C. J., Nolte, G., & Daffertshofer, A. (2007). Phase lag index: assessment of functional connectivity from multi channel EEG and MEG with diminished bias from common sources. Human brain mapping, 28(11), 1178-1193.
- Hardmeier2014
Hardmeier, M., Hatz, F., Bousleiman, H., Schindler, C., Stam, C. J., & Fuhr, P. (2014). Reproducibility of functional connectivity and graph measures based on the phase lag index (PLI) and weighted phase lag index (wPLI) derived from high resolution EEG. PloS one, 9(10), e108648.
-
dyconnmap.ts.permutation_entropy.
permutation_entropy
(signal: np.ndarray[np.int32], m: int, tau: int) → float[source]¶ Permutation Entropy
- Parameters
signal (array-like, shape(N)) – Symblic time series (1D).
m (int) – Embedding dimension.
tau (int) – Time delay parameter.
- Returns
pe (float) – Permutation entropy.
npe (float) – Normalized permutation entropy.
dyconnmap.ts.rr_order_patterns module¶
Order Reccurence Plot
- Stam2007
Stam, C. J., Nolte, G., & Daffertshofer, A. (2007). Phase lag index: assessment of functional connectivity from multi channel EEG and MEG with diminished bias from common sources. Human brain mapping, 28(11), 1178-1193.
- Hardmeier2014
Hardmeier, M., Hatz, F., Bousleiman, H., Schindler, C., Stam, C. J., & Fuhr, P. (2014). Reproducibility of functional connectivity and graph measures based on the phase lag index (PLI) and weighted phase lag index (wPLI) derived from high resolution EEG. PloS one, 9(10), e108648.
-
dyconnmap.ts.rr_order_patterns.
rr_order_patterns
(signal1: np.ndarray[np.int32], signal2: np.ndarray[np.int32], m: int, tau: int) → float[source]¶ - Parameters
signal1 –
signal2 –
m (int) – Embedding dimension.
tau (int) – Time delay parameter.
Notes
The results may vary from the original MATLAB script because of the permutations’ order.
The results may vary from the original MATLAB script because of the order of the indices in the :python:`numpy.where`.
The permutations are generated from \([1, dim+1]\) so there are no occurances of \(0.\)
The extra \(+1\) in the lines .. python: I = sklearn.preprocessing.normalize(I + 1) is in order to avoid :math:`0`s.
- Returns
cstr – Coupling strength.
- Return type
float
dyconnmap.ts.sampen module¶
Sample Entropy
Notes
Based on https://nl.mathworks.com/matlabcentral/fileexchange/35784-sample-entropy
- Stam2007
Stam, C. J., Nolte, G., & Daffertshofer, A. (2007). Phase lag index: assessment of functional connectivity from multi channel EEG and MEG with diminished bias from common sources. Human brain mapping, 28(11), 1178-1193.
- Hardmeier2014
Hardmeier, M., Hatz, F., Bousleiman, H., Schindler, C., Stam, C. J., & Fuhr, P. (2014). Reproducibility of functional connectivity and graph measures based on the phase lag index (PLI) and weighted phase lag index (wPLI) derived from high resolution EEG. PloS one, 9(10), e108648.
-
dyconnmap.ts.sampen.
sample_entropy
(data: np.ndarray[np.int32], dim: Optional[int] = 2, tau: Optional[int] = None, r: Optional[float] = None) → float[source]¶ Sample Entropy
- Parameters
data (array-like, shape(n_samples)) – Symbolic time series.
dim (int) – Embedding dimension. Default 2.
tau (int) – Delay time for downsampling. Is None, 1 is passed.
r (float) – Tolerance factor. If None, 0.2 * std(data) is passed.
- Returns
SampEn – Sample entropy.
- Return type
float
See also
dyconnmap.ts.embed_ts
Embedded timeseries
dyconnmap.ts.ste module¶
Symbolic Transfer Entropy
-
dyconnmap.ts.ste.
entropy_reduction_rate
(sym_ts: np.ndarray[np.float32]) → float[source]¶ Entropy Reduction Rate
- Parameters
sym_ts (array-like, shape(n_samples)) – Input symblic time series.
- Returns
entredrate – The estimated entropy reduction rate.
- Return type
float
-
dyconnmap.ts.ste.
symoblic_transfer_entropy
(x: np.ndarray[np.int32], y: np.ndarray[np.int32], s: Optional[int] = 1, delay: Optional[int] = 0, verbose: Optional[bool] = False) → Tuple[float, float, float][source]¶ Symbolic Tranfer Entropy
- Parameters
x (array-like, shape(N)) – Symblic time series (1D).
y (array-like, shape(N)) – Symbolic time series (1D).
s (int) – Embedding dimension.
delay (int) – Time delay parameter
verbose (boolean) – Print computation messages.
- Returns
tent_diff (float) – The difference of the tranfer entropies of the two time series.
tentxy (float) – The estimated tranfer entropy of x -> y.
tentyx (float) – The estimated tranfer entropy of y -> x.
dyconnmap.ts.surrogates module¶
Surrogate Analysis
-
dyconnmap.ts.surrogates.
aaft
(ts: np.ndarray[np.float32], num_surr: Optional[int] = 1, rng: Optional[numpy.random.mtrand.RandomState] = None) → np.ndarray[np.float32][source]¶ Amplitude Adjusted Fourier Transform
- Parameters
ts –
num_surr –
rng (object or None) – An object of type numpy.random.RandomState
-
dyconnmap.ts.surrogates.
fdr
(p_values: np.ndarray[np.float32], q: Optional[float] = 0.01, method: Optional[str] = 'pdep') → Tuple[bool, float][source]¶ False Discovery Rate
- Parameters
p_values –
q –
method –
-
dyconnmap.ts.surrogates.
phase_rand
(data, num_surr: Optional[int] = 1, rng: Optional[numpy.random.mtrand.RandomState] = None) → np.ndarray[np.float32][source]¶ Phase-randomized suggorates
- Parameters
data –
num_surr –
rng (object or None) – An object of type numpy.random.RandomState
-
dyconnmap.ts.surrogates.
surrogate_analysis
(ts1: np.ndarray[np.float32], ts2: np.ndarray[np.float32], num_surr: Optional[int] = 1000, estimator_func: Optional[Callable[[np.ndarray[np.float32], np.ndarray[np.float32]], float]] = None, ts1_no_surr: bool = False, rng: Optional[numpy.random.mtrand.RandomState] = None) → Tuple[float, np.ndarray[np.int32], np.ndarray[np.float32], float][source]¶ Surrogate Analysis
- Parameters
ts1 –
ts2 –
num_surr (int) –
estimator_func (function) –
ts1_no_surr (boolean) –
rng (object or None) – An object of type numpy.random.RandomState
- Returns
p_val (float)
corr_surr
surrogates
r_value (float)
dyconnmap.ts.teager_kaiser_energy module¶
Teager–Kaiser Operator
ref: https://www.c-motion.com/v3dwiki/index.php/Teager_Kaiser_Energy
dyconnmap.ts.wald module¶
Wald test
Module contents¶
-
dyconnmap.ts.
aaft
(ts: np.ndarray[np.float32], num_surr: Optional[int] = 1, rng: Optional[numpy.random.mtrand.RandomState] = None) → np.ndarray[np.float32][source]¶ Amplitude Adjusted Fourier Transform
- Parameters
ts –
num_surr –
rng (object or None) – An object of type numpy.random.RandomState
-
dyconnmap.ts.
complexity_index
(x: np.ndarray[np.int32], sub_len: Optional[int] = - 1, normalize: Optional[bool] = False, iterations: Optional[int] = 100) → Union[Tuple[numpy.float32, np.ndarray[np.int32]], Tuple[numpy.float32, numpy.float32, np.ndarray[np.int32]]][source]¶ Complexity Index
- Parameters
x (array-like, shape(n_samples)) – Input symbolic time series.
sub_len (int) – Maximum subword length. Default is len(x) - 1.
normalize (bool) – Normalize result. Default is False.
iterationss (int) – Number of iterations to perform randomization. Default is 100.
- Returns
normal_ci (float) – The computed omplexity index after normalization against the randomization procedure.
ci (float) – The computed complexity index.
spectrum (array-like) – A list of the number of distinct subwords of length 1, up to the size of the input symbolic time series.
-
dyconnmap.ts.
cv
(x: numpy.ndarray) → float[source]¶ Coefficient of Variation
- Parameters
x (array-like, shape(n_samples)) – Input time series
- Returns
cv – The computed coefficient of variation.
- Return type
float
-
dyconnmap.ts.
dcorr
(x: numpy.ndarray, y: numpy.ndarray) → float[source]¶ Distance Correlation
- Parameters
x (array-like, shape(n_samples)) – Input time series.
y (array-like, shape(N)) – Input time series.
- Returns
val – The computed distance correlation.
- Return type
float
-
dyconnmap.ts.
embed_delay
(ts: np.ndarray[np.float32], dim: int, tau: int) → Optional[np.ndarray[np.float32]][source]¶ Embed delay
- Parameters
ts (array-like, shape(n_samples)) – One-dimensional symbolic time series.
dim (int) – The embedding dimension.
tau (int) – Time delay factor.
- Returns
y – The embedded timeseries.
- Return type
array-like
-
dyconnmap.ts.
entropy
(x: np.ndarray[np.float32]) → float[source]¶ Entropy
- Parameters
x (array-like, shape(N)) – Input symbolic time series.
- Returns
entropy – The computed entropy.
- Return type
float
-
dyconnmap.ts.
entropy_reduction_rate
(sym_ts: np.ndarray[np.float32]) → float[source]¶ Entropy Reduction Rate
- Parameters
sym_ts (array-like, shape(n_samples)) – Input symblic time series.
- Returns
entredrate – The estimated entropy reduction rate.
- Return type
float
-
dyconnmap.ts.
fdr
(p_values: np.ndarray[np.float32], q: Optional[float] = 0.01, method: Optional[str] = 'pdep') → Tuple[bool, float][source]¶ False Discovery Rate
- Parameters
p_values –
q –
method –
-
dyconnmap.ts.
fisher_score
(x: numpy.ndarray, y: numpy.ndarray) → numpy.ndarray[source]¶ - Parameters
x –
y –
-
dyconnmap.ts.
fisher_z
(data)[source]¶ Fisher’s z-transformation
For a given dataset \(p\) bound to \([0.0, 1.0]\), we can use Fisher’s z-transformation to normalize it in an approximately Gaussian distribution.
This transformation is computed as follows:
\[z_p := \frac{1}{2} \text{ln} \left ( \frac{1+p}{1-p} \right ) = \text{arctanh}(p)\]- Parameters
data –
-
dyconnmap.ts.
fisher_z_plv
(data)[source]¶ - \[z^p_j = sin^{-1}(2 * PLV_j - 1)\]
- Returns
|
—–
.. [Mormann2005] Mormann, F., Fell, J., Axmacher, N., Weber, B., Lehnertz, K., Elger, C. E., & Fernández, G. (2005). Phase/amplitude reset and theta–gamma interaction in the human medial temporal lobe during a continuous word recognition memory task. Hippocampus, 15(7), 890-900.
-
dyconnmap.ts.
fnn
(ts: np.ndarray[np.float32], tau: int, max_dim: Optional[int] = 20, neighbors_reduction: Optional[float] = 0.1, rtol: Optional[float] = 15.0, atol: Optional[float] = 2.0) → Optional[int][source]¶ False Nearest Neighbors
Notes
The execution stops either when the maxium number of embedding dimensions is reached, or the the number of neighbors is reduced to specific percentage.
- Parameters
ts (array-like, 1d) –
tau (int) – Time-delay parameter.
max_dim (int) – Maximum embedding dimension.
neighbors_reduction (float) – Maximum percentage of neighbors reduction. Default ‘0.10’ (10%).
rtol (float) – First threshold, criterion to identify a false neighbor. (Neighborhood size)
atol (float) – Second threshold, criterion to identify a false neighbor.
- Returns
min_dimension – Minimum embedding dimension.
- Return type
int
-
dyconnmap.ts.
icc_31
(X: np.ndarray[np.float32]) → float[source]¶ ICC (3,1)
- Parameters
X – Input data
- Returns
icc – Intra-class correlation.
- Return type
float
-
dyconnmap.ts.
markov_matrix
(symts: np.ndarray[np.int32], states_from_length: Optional[bool] = True) → np.ndarray[np.float32][source]¶ Markov Matrix
Markov matrix (also refered as “transition matrix”) is a square matrix that tabulates the observed transition probabilities between symbols for a finite Markov Chain. It is a first-order descriptor by which the next symbol depends only on the current symbol (and not on the previous ones); a Markov Chain model.
A transition matrix is formally depicted as:
Given the probability \(Pr(j|i)\) of moving between \(i\) and \(j\) elements, the transition matrix is depicted as:
\[\begin{split}P = \begin{pmatrix} P_{1,1} & P_{1,2} & \ldots & P_{1,j} & \ldots & P_{1,S} \\ P_{2,1} & P_{2,2} & \ldots & P_{2,j} & \ldots & P_{2,S} \\ \vdots & \vdots & \ddots & \vdots & \ddots & \vdots \\ P_{i,1} & P_{i,2} & \ldots & P_{i,j} & \ldots & P_{i,S} \\ \vdots & \vdots & \ddots & \vdots & \ddots & \vdots \\ P_{S,1} & P_{S,2} & \ldots & P_{S,j} & \ldots & P_{S,S} \\ \end{pmatrix}\end{split}\]Since the transition matrix is row-normalized, so as the total transition probability from state \(i\) to all the others must be equal to \(1\).
For more properties consult, among other links WolframMathWorld_ and WikipediaMarkovMatrix_.
- WolframMathWorld
- WikipediaMarkovMatrix
- Parameters
symts (array-like, shape(N)) – One-dimensional discrete time series.
states_from_length (bool or int, optional) – Used to account symbolic time series in which not all the symbols are present. That may happen when for example the symbols are drawn from different distributions. Default True, the size of the resulting Markov Matrix is equal to the number of unique symbols present in the time series. If False, the size will be the highest symbolic state + 1. You may also speficy the highest (inclusive) symbolic state.
- Returns
mtx – The transition matrix. The size depends the parameter states_from_length.
- Return type
matrix
-
dyconnmap.ts.
occupancy_time
(symts: np.ndarray[np.int32], symbol_states: numpy.int32 = None, weight: Optional[Union[numpy.float32, np.ndarray[np.float32]]] = None) → Tuple[numpy.float64, np.ndarray[np.int32]][source]¶ Occupancy Time
- Parameters
symts –
symbol_states (int) – The maximum number of symbols. This is useful to define in case your symbolic timeseries skips some states, in which case would produce a matrix of different size.
weight (float) – The weights of the reuslting transition symbols. Default len(symts).
- Returns
oc
symbols
-
dyconnmap.ts.
ordinal_pattern_similarity
(signal1: np.ndarray[np.int32], signal2: np.ndarray[np.int32], m: int, tau: int) → Tuple[float, np.ndarray[np.int32], np.ndarray[np.float32]][source]¶ Ordinal Pattern Similarity
- Parameters
signal1 –
signal2 –
m (int) – Embedding dimension.
tau (int) – Time delay parameter.
Notes
The results may vary from the original MATLAB script because of the permutations’ order.
The permutations are generated from \([1, dim+1]\) so there are no occurances of \(0.\)
The extra \(+1\) in the lines .. python: I = sklearn.preprocessing.normalize(I + 1) is in order to avoid :math:`0`s.
- Returns
dissimilarity (float) – The dissimilarity index as computed from the ordinal patterns.
ordinal_patterns (array) – The time series of ordinal patterns for input signals.
patterns_distribution (array) – Distribution of the patterns.
-
dyconnmap.ts.
permutation_entropy
(signal: np.ndarray[np.int32], m: int, tau: int) → float[source]¶ Permutation Entropy
- Parameters
signal (array-like, shape(N)) – Symblic time series (1D).
m (int) – Embedding dimension.
tau (int) – Time delay parameter.
- Returns
pe (float) – Permutation entropy.
npe (float) – Normalized permutation entropy.
-
dyconnmap.ts.
phase_rand
(data, num_surr: Optional[int] = 1, rng: Optional[numpy.random.mtrand.RandomState] = None) → np.ndarray[np.float32][source]¶ Phase-randomized suggorates
- Parameters
data –
num_surr –
rng (object or None) – An object of type numpy.random.RandomState
-
dyconnmap.ts.
rr_order_patterns
(signal1: np.ndarray[np.int32], signal2: np.ndarray[np.int32], m: int, tau: int) → float[source]¶ - Parameters
signal1 –
signal2 –
m (int) – Embedding dimension.
tau (int) – Time delay parameter.
Notes
The results may vary from the original MATLAB script because of the permutations’ order.
The results may vary from the original MATLAB script because of the order of the indices in the :python:`numpy.where`.
The permutations are generated from \([1, dim+1]\) so there are no occurances of \(0.\)
The extra \(+1\) in the lines .. python: I = sklearn.preprocessing.normalize(I + 1) is in order to avoid :math:`0`s.
- Returns
cstr – Coupling strength.
- Return type
float
-
dyconnmap.ts.
sample_entropy
(data: np.ndarray[np.int32], dim: Optional[int] = 2, tau: Optional[int] = None, r: Optional[float] = None) → float[source]¶ Sample Entropy
- Parameters
data (array-like, shape(n_samples)) – Symbolic time series.
dim (int) – Embedding dimension. Default 2.
tau (int) – Delay time for downsampling. Is None, 1 is passed.
r (float) – Tolerance factor. If None, 0.2 * std(data) is passed.
- Returns
SampEn – Sample entropy.
- Return type
float
See also
dyconnmap.ts.embed_ts
Embedded timeseries
-
dyconnmap.ts.
surrogate_analysis
(ts1: np.ndarray[np.float32], ts2: np.ndarray[np.float32], num_surr: Optional[int] = 1000, estimator_func: Optional[Callable[[np.ndarray[np.float32], np.ndarray[np.float32]], float]] = None, ts1_no_surr: bool = False, rng: Optional[numpy.random.mtrand.RandomState] = None) → Tuple[float, np.ndarray[np.int32], np.ndarray[np.float32], float][source]¶ Surrogate Analysis
- Parameters
ts1 –
ts2 –
num_surr (int) –
estimator_func (function) –
ts1_no_surr (boolean) –
rng (object or None) – An object of type numpy.random.RandomState
- Returns
p_val (float)
corr_surr
surrogates
r_value (float)
-
dyconnmap.ts.
symoblic_transfer_entropy
(x: np.ndarray[np.int32], y: np.ndarray[np.int32], s: Optional[int] = 1, delay: Optional[int] = 0, verbose: Optional[bool] = False) → Tuple[float, float, float][source]¶ Symbolic Tranfer Entropy
- Parameters
x (array-like, shape(N)) – Symblic time series (1D).
y (array-like, shape(N)) – Symbolic time series (1D).
s (int) – Embedding dimension.
delay (int) – Time delay parameter
verbose (boolean) – Print computation messages.
- Returns
tent_diff (float) – The difference of the tranfer entropies of the two time series.
tentxy (float) – The estimated tranfer entropy of x -> y.
tentyx (float) – The estimated tranfer entropy of y -> x.
-
dyconnmap.ts.
teager_kaiser_energy
(ts: np.ndarray[np.float32]) → np.ndarray[np.float32][source]¶ Teager Kaiser Energy
- Parameters
ts (array of size [1 x samples]) –