pyhctsa.operations.symbolic.coarse_grain¶
- pyhctsa.operations.symbolic.coarse_grain(y, how_to_cg, num_groups)¶
Coarse-grains a continuous time series to a discrete alphabet.
- Parameters:¶
- y : array-like¶
The input time series.
- how_to_cg : str¶
The method of coarse-graining. Options:
’quantile’: an equiprobable alphabet by the value of each point,
’diff’: as ‘quantile’, but applied to the increments
diff(y): an equiprobable alphabet by the value of each increment (not a literal sign split; this was called ‘updown’ before hctsa renamed it),’updown’: a true binary up/down split by the raw sign of each increment (
diff(y) > 0gives symbol 2, otherwise 1);num_groupsmust be 2. Unlike the other methods this is NOT equiprobable: the two states can be arbitrarily imbalanced for a drifting series,’embed2quadrants’, ‘embed2octants’: the alphabet is the quadrant (4 symbols) or octant (8 symbols) of each point of a 2-D time-delay embedding.
- num_groups : int or str¶
The size of the alphabet for ‘quantile’ and ‘diff’ (must be 2 for ‘updown’), or the time delay for the embedding methods: a number of samples, or a string that sets it from the series:
'ac1e'(the floor of the first 1/e crossing of the autocorrelation function),'mi'(the smaller of the first minimum of the Kraskov automutual information and the ‘ac1e’ delay; seepyhctsa.utils.get_tau()), or'tau'(the first zero-crossing of the autocorrelation function, kept for backward compatibility). A delay is capped at floor(N/25).
- Returns:¶
yth – The coarse-grained time series. NaN (a scalar) if the embedding delay for ‘embed2quadrants’/’embed2octants’ cannot be determined (
num_groups='tau'or'ac1e'for a constant series, or'ac1e'for a series whose autocorrelation function never falls to 1/e).- Return type:¶
array-like