pyhctsa.operations.symbolic.transition_matrix

pyhctsa.operations.symbolic.transition_matrix(y, how_to_cg='quantile', num_groups=2, tau=1)

Transition probabilities between time-series states. The time series is coarse-grained according to a given method.

The input time series is transformed into a symbolic string using an equiprobable alphabet of num_groups letters. The transition probabilities are calculated at a lag tau.

Related to the idea of quantile graphs from time series, cf. [1]

References

Parameters:
y : array-like

Input time series.

how_to_cg : str, optional

The method of discretization: 'quantile' (equiprobable, the default) or 'updown' (a true binary up/down split by the sign of each increment: NOT equiprobable, and requires num_groups=2; see coarse_grain()). 'diff' (equiprobable by increment) is also accepted.

num_groups : int, optional

number of groups in the course-graining. Default is 2.

tau : int or str, optional

The lag of the transitions. The whole series is discretized to states s, and the transitions are the pairs (s[t], s[t + tau]) for every t; for ‘diff’ and ‘updown’ the states code the increments at lag tau, y[t + tau] - y[t]. An integer, or a rule that sets it from the series: 'ac' (the first zero-crossing of the autocorrelation function), 'ac1e' (the floor of its first 1/e crossing) or 'mi' (the smaller of the first minimum of the Kraskov automutual information and the ‘ac1e’ delay), or one of these computed from the ranks of the series ('ac-rank', 'ac1e-rank', 'mi-rank'); see pyhctsa.utils.get_tau(). With ‘quantile’ or ‘updown’ and a rank-based rule, the result is unchanged by a strictly increasing transformation of the series. Default is 1. NaN is returned if tau cannot be determined or leaves no transition.

Returns:

A dictionary including the transition probabilities themselves, as well as the trace of the transition matrix, measures of asymmetry (symdiff, symsumdiff and the Kullback-Leibler divergence transKLdiv between the matrix and its transpose), eigenvalues of the transition matrix (including secondeig, specgap and lam2mod, the modulus of the second-largest-modulus eigenvalue of the row-normalized matrix), and the Miller-Madow-corrected conditional entropy of the next state transEntropy. NaN is returned if tau cannot be determined or leaves no transition. Note that the matrix is normalized by the number of transitions, so it holds joint (not row-normalized) probabilities.

Return type:

dict