pyhctsa.operations.entropy.randomize_ordinal¶
-
pyhctsa.operations.entropy.randomize_ordinal(y, tau=
1)¶ How quickly ordinal-pattern structure is lost as a series is randomized.
The series is randomized progressively: at each step, one randomly chosen sample is overwritten by a value copied from a randomly chosen sample of the original series (the ‘statdist’ scheme of
randomize()). Rather than simulating this, the function computes exactly (with no random draws) the expected distribution of the ordinal patterns of order 3 (the patterns of Bandt and Pompe’s permutation entropy [1], PermEn(3, tau)) aftertsteps, and reports how quickly the ordinal structure of the series is lost. Port of hctsa’sEN_RandomizeOrdinal.The calculation is exact because, after
tsteps, each sample has either never been overwritten, or it holds a value drawn independently and uniformly from the original series. For a window of three samples, the probability that exactly a given subset ofkof them has never been overwritten isw_k(t) = sum_{j=0}^{3-k} C(3-k, j) (-1)^j (1 - (k+j)/N)^t. Given the subset, the pattern probabilities follow from the kept values and the empirical distribution function of the series. As inpermutation_entropy(), ties are first broken in a fixed pseudo-random order (_break_ties()), so equal values are not read as increasing. The expected pattern distribution aftertsteps is therefore a fixed combination of eight series-specific pattern distributions (one per subset), weighted byw_k(t).References
- Parameters:¶
- Returns:¶
‘halftime’: the randomization time
t/N(the number of replacements per sample) at which the permutation entropy of the expected pattern distribution is halfway between its value for the original series and its value for the fully randomized series (NaN if the two are equal to within rounding error, so that nothing decays). A long halftime means that much of the ordinal structure survives the replacement of single samples (it is carried by the order of pairs of samples); a short one that it depends on the joint configuration of all three samples of a window,’normPermEn0’: the normalized PermEn(3, tau) of the original series,
’normPermEnRep1’: the normalized permutation entropy of the expected pattern distribution when one sample of each window (chosen at random) is replaced by an independent draw from the series,
’normPermEnInf’: the normalized permutation entropy of the fully randomized series (close to 1, less a bias of order
1/Nfrom drawing the same sample twice).
NaN (instead of a dict) if the series is too short (fewer than 5 windows) or the delay cannot be determined.
- Return type:¶
dict
Notes
The entropy is that of the expected pattern distribution (not the expected entropy of a single randomized series, which is lower by a small finite-sample bias), so the result is deterministic. The ‘dyndist’ and ‘permute’ schemes give the same expected pattern distribution to leading order in
1/N(‘permute’ at twice the rate).