Calculate Approximate Entropy (ApEn) of a time series
Source:R/fwave.R
calculate_approximate_entropy.Rd
This function computes the approximate entropy (ApEn) of a time series using the method described by Pincus (1991). ApEn is a measure of the regularity and complexity of the time series. It is calculated by comparing vectors derived from the time series in an m-dimensional embedded space and in an (m+1)-dimensional space. The basic steps are:
Embedding: The time series is embedded into vectors of length m (and m+1) by taking successive elements. For a time series of length N, this produces (N - m + 1) (or (N - m) for m+1) vectors.
Distance Calculation: For each pair of embedded vectors, the Chebyshev distance (i.e., the maximum absolute difference among corresponding elements) is computed. If the distance between two vectors is less than or equal to a tolerance r, they are considered "similar."
Counting and Averaging: For each embedded vector, the function counts the number of similar vectors (including itself) and takes the natural logarithm of the ratio of this count to the total number of vectors. These log-values are then averaged to yield a statistic phi.
ApEn Calculation: The approximate entropy is the difference between the phi computed for dimension m and the phi computed for dimension m+1, i.e., ApEn = phi(m) - phi(m+1).
The tolerance r is typically chosen as a multiple of the standard deviation of the time series (commonly 3.5 * sd(x)). If r is not provided (or is negative), it is calculated automatically.