dynsight.analysis.sample_entropy

dynsight.analysis.sample_entropy(time_series, r_factor, m_par=2)[source]

Computes the Sample Entropy of a single time-series.

The Chebyshev distance is used. SampEn takes values between 0 and +inf. If the time-series is too short for the chosen m_par, raises ValueError. If no matching sequences can be found, raises RuntimeError.

Parameters:
  • time_series (NDArray[np.float64]) – np.ndarray of shape (n_frames,) The time-series data.

  • r_factor (np.float64 | float) – float The similarity threshold between signal windows. A common choice is 0.2 * the standard deviation of the time-series.

  • m_par (int) – int (default 2) The m parameter (length of the considered overlapping windows).

Returns:

Sample entropy of the input time-series.

Return type:

float

Example

import numpy as np
from dynsight.analysis import sample_entropy

np.random.seed(1234)
data = np.random.rand(100)
r_factor = 0.5 * np.std(data)

sampen = sample_entropy(
    data,
    r_factor=r_factor,
    m_par=2,
)