Approximate entropy


In statistics, an approximate entropy is a technique used to quantify the amount of regularity and the unpredictability of fluctuations over time-series data.
For example, there are two series of data:
Moment statistics, such as mean and variance, will not distinguish between these two series. Nor will rank order statistics distinguish between these series. Yet series 1 is "perfectly regular"; knowing one term has the value of 20 enables one to predict with certainty that the next term will have the value of 10. Series 2 is randomly valued; knowing one term has the value of 20 gives no insight into what value the next term will have.
Regularity was originally measured by exact regularity statistics, which has mainly centered on various entropy measures.
However, accurate entropy calculation requires vast amounts of data, and the results will be greatly influenced by system noise, therefore it is not practical to apply these methods to experimental data. ApEn was developed by Steve M. Pincus to handle these limitations by modifying an exact regularity statistic, Kolmogorov–Sinai entropy. ApEn was initially developed to analyze medical data, such as heart rate, and later spread its applications in finance, psychology, and human factors engineering.

The algorithm

in which is defined as
The are the scalar components of. represents the distance between the vectors and, given by the maximum difference in their respective scalar components. Note that takes on all values, so the match provided when will be counted.
where is the natural logarithm, for and fixed as in Step 2.
Parameter selection: typically choose or, and depends greatly on the application.
An implementation on Physionet, which is based on Pincus use whereas the original article uses in Step 4. While a concern for artificially constructed examples, it is usually not a concern in practice.

The interpretation

The presence of repetitive patterns of fluctuation in a time series renders it more predictable than a time series in which such patterns are absent. ApEn reflects the likelihood that similar patterns of observations will not be followed by additional similar observations. A time series containing many repetitive patterns has a relatively small ApEn; a less predictable process has a higher ApEn.

One example

Suppose, and the sequence consists of 51 samples of heart rate equally spaced in time:
. Let's choose and .
Form a sequence of vectors:
Distance is calculated as follows:
Note, so
Similarly,
Therefore, such that include, and the total number is 17.
Please note in Step 4, for, . So the such that include, and the total number is 16.
Then we repeat the above steps for m=3. First form a sequence of vectors:
By calculating distances between vector, we find the vectors satisfying the filtering level have the following characteristic:
Therefore,
Finally,
The value is very small, so it implies the sequence is regular and predictable, which is consistent with the observation.

Python implementation


import numpy as np
def ApEn -> float:
"""Approximate_entropy."""
def _maxdist:
return max for ua, va in zip
def _phi:
x = U for j in range] for i in range]
C =
return ** * sum
N = len
return abs - _phi)
  1. Usage example
U = np.array
print
1.0996541105257052e-05
randU = np.random.choice
print
0.8626664154888908

Advantages

The advantages of ApEn include:
ApEn has been applied to classify EEG in psychiatric diseases, such as schizophrenia, epilepsy, and addiction.

Limitations

The ApEn algorithm counts each sequence as matching itself to avoid the occurrence of ln in the calculations. This step might cause bias of ApEn and this bias causes ApEn to have two poor properties in practice:
  1. ApEn is heavily dependent on the record length and is uniformly lower than expected for short records.
  2. It lacks relative consistency. That is, if ApEn of one data set is higher than that of another, it should, but does not, remain higher for all conditions tested.