ktk.cycles.most_repeatable_cycles#
- most_repeatable_cycles(data, /)[source]#
Get the indexes of the most repeatable cycles in array.
This function returns an ordered list of the most repeatable to the least repeatable cycles.
It works by recursively discarding the cycle than maximizes the root-mean-square error between the cycle and the average of every remaining cycle, until there are only two cycles remaining. The function returns a list that is the reverse order of cycle removal: first the two last cycles, then the last-removed cycle, and so on. If two cycles are as equivalently repeatable, they are returned in order of appearance.
Cycles that include at least one NaN are excluded.
- Parameters:
data (ArrayLike) – Stacked time-normalized data to analyze, in the shape (n_cycles, n_points).
- Returns:
list of indexes corresponding to the cycles in most to least repeatable order.
- Return type:
list[int]
Example
>>> import kineticstoolkit.lab as ktk >>> import numpy as np >>> # Create a data sample with four different cycles, the most different >>> # being cycle 2 (cos instead of sin), then cycle 0. >>> x = np.arange(0, 10, 0.1) >>> data = np.array([np.sin(x), np.sin(x) + 0.14, np.cos(x) + 0.14, np.sin(x) + 0.15])
>>> ktk.cycles.most_repeatable_cycles(data) [1, 3, 0, 2]