HOME

TheInfoList



OR:

In
statistics Statistics (from German language, German: ''wikt:Statistik#German, Statistik'', "description of a State (polity), state, a country") is the discipline that concerns the collection, organization, analysis, interpretation, and presentation of ...
, an approximate entropy (ApEn) is a technique used to quantify the amount of regularity and the
unpredictability Predictability is the degree to which a correct prediction or forecast of a system's state can be made, either qualitatively or quantitatively. Predictability and causality Causal determinism has a strong relationship with predictability. Perfe ...
of fluctuations over
time-series In mathematics, a time series is a series of data points indexed (or listed or graphed) in time order. Most commonly, a time series is a sequence taken at successive equally spaced points in time. Thus it is a sequence of discrete-time data. Ex ...
data. For example, consider two series of data: : Series A: (0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, ...), which alternates 0 and 1. : Series B: (0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, ...), which has either a value of 0 or 1, chosen randomly, each with probability 1/2. Moment statistics, such as
mean There are several kinds of mean in mathematics, especially in statistics. Each mean serves to summarize a given group of data, often to better understand the overall value (magnitude and sign) of a given data set. For a data set, the ''arithme ...
and
variance In probability theory and statistics, variance is the expectation of the squared deviation of a random variable from its population mean or sample mean. Variance is a measure of dispersion, meaning it is a measure of how far a set of numbers ...
, will not distinguish between these two series. Nor will
rank order A ranking is a relationship between a set of items such that, for any two items, the first is either "ranked higher than", "ranked lower than" or "ranked equal to" the second. In mathematics, this is known as a weak order or total preorder of ...
statistics distinguish between these series. Yet series A is perfectly regular: knowing a term has the value of 1 enables one to predict with certainty that the next term will have the value of 0. In contrast, series B is randomly valued: knowing a term has the value of 1 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 In mathematics, a measure-preserving dynamical system is an object of study in the abstract formulation of dynamical systems, and ergodic theory in particular. Measure-preserving systems obey the Poincaré recurrence theorem, and are a special ...
. ApEn was initially developed to analyze medical data, such as heart rate, and later spread its applications in
finance Finance is the study and discipline of money, currency and capital assets. It is related to, but not synonymous with economics, the study of production, distribution, and consumption of money, assets, goods and services (the discipline of fina ...
,
physiology Physiology (; ) is the scientific study of functions and mechanisms in a living system. As a sub-discipline of biology, physiology focuses on how organisms, organ systems, individual organs, cells, and biomolecules carry out the chemical ...
,
human factors engineering Human factors and ergonomics (commonly referred to as human factors) is the application of psychological and physiological principles to the engineering and design of products, processes, and systems. Four primary goals of human factors learnin ...
, and climate sciences.


Algorithm

A comprehensive step-by-step tutorial with an explanation of the theoretical foundations of Approximate Entropy is available. The algorithm is: ; Step 1: Assume a time series of data u(1), u(2),\ldots, u(N). These are N raw data values from measurements equally spaced in time. ; Step 2: Let m \in \mathbb^+ be a positive
integer An integer is the number zero (), a positive natural number (, , , etc.) or a negative integer with a minus sign (−1, −2, −3, etc.). The negative numbers are the additive inverses of the corresponding positive numbers. In the language ...
, with m \leq N, which represents the length of a run of data (essentially a
window A window is an opening in a wall, door, roof, or vehicle that allows the exchange of light and may also allow the passage of sound and sometimes air. Modern windows are usually glazed or covered in some other transparent or translucent materia ...
).
Let r \in \mathbb^+ be a positive
real number In mathematics, a real number is a number that can be used to measure a ''continuous'' one-dimensional quantity such as a distance, duration or temperature. Here, ''continuous'' means that values can have arbitrarily small variations. Every real ...
, which specifies a filtering level.
Let n=N-m+1. ; Step 3: Define \mathbf(i) = \big (i),u(i+1),\ldots,u(i+m-1)\big/math> for each i where 1 \leq i \leq n. In other words, \mathbf(i) is an m-dimensional
vector Vector most often refers to: *Euclidean vector, a quantity with a magnitude and a direction *Vector (epidemiology), an agent that carries and transmits an infectious pathogen into another living organism Vector may also refer to: Mathematic ...
that contains the run of data starting with u(i).
Define the distance between two vectors \mathbf(i) and \mathbf(j) as the maximum of the distances between their respective components, given by :: \begin d mathbf(i),\mathbf(j) & = \max_k \big(, \mathbf(i)_k - \mathbf(j)_k, \big) \\ & = \max_k \big(, u(i+k-1) - u(j+k-1), \big) \\ \end : for 1 \leq k \leq m. ; Step 4: Define a count C^m_i as :: C_i^m (r)= : for each i where 1 \leq i,j \leq n. Note that since j takes on all values between 1 and n, the match will be counted when j=i (i.e. when the test subsequence, \mathbf(j), is matched against itself, \mathbf(i)). ; Step 5: Define :: \phi ^m (r) = \sum_^\log (C_i^m (r)) : where \log is the
natural logarithm The natural logarithm of a number is its logarithm to the base of the mathematical constant , which is an irrational and transcendental number approximately equal to . The natural logarithm of is generally written as , , or sometimes, if ...
, and for a fixed m , r , and n as set in Step 2. ; Step 6: Define approximate entropy (\mathrm) as :: \mathrm(m,r,N)(u) = \phi ^m (r) - \phi^ (r) ;Parameter selection: Typically, choose m=2 or m=3 , whereas r depends greatly on the application. An implementation on Physionet, which is based on Pincus, use d mathbf(i), \mathbf(j)< r instead of d mathbf(i), \mathbf(j)\le r in Step 4. While a concern for artificially constructed examples, it is usually not a concern in practice.


Example

Consider a sequence of N=51 samples of heart rate equally spaced in time: : \ S_N = \ Note the sequence is periodic with a period of 3. Let's choose m=2 and r=3 (the values of m and r can be varied without affecting the result). Form a sequence of vectors: :\begin \mathbf(1) & = (1) \ u(2) 5 \ 80\ \mathbf(2) & = (2) \ u(3) 0 \ 89\ \mathbf(3) & = (3) \ u(4) 9 \ 85\ \mathbf(4) & = (4) \ u(5) 5 \ 80\ & \ \ \vdots \end Distance is calculated repeatedly as follows. In the first calculation, :\ d mathbf(1), \mathbf(1)\max_k , \mathbf(1)_k - \mathbf(1)_k, =0 which is less than r . In the second calculation, note that , u(2)-u(3), > , u(1)-u(2), , so :\ d mathbf(1), \mathbf(2)\max_k , \mathbf(1)_k-\mathbf(2)_k, =, u(2)-u(3), =9 which is greater than r . Similarly, :\begin d mathbf(1) &, \mathbf(3)= , u(2)-u(4), = 5>r\\ d mathbf(1) &, \mathbf(4)= , u(1)-u(4), = , u(2)-u(5), = 0mathbf(1) &, \mathbf(j)= \cdots \\ & \vdots \\ \end The result is a total of 17 terms \mathbf(j) such that d mathbf(1), \mathbf(j)le r . These include \mathbf(1), \mathbf(4), \mathbf(7),\ldots,\mathbf(49). In these cases, C^m_i(r) is :\ C_1^2 (3)=\frac :\ C_2^2 (3)=\frac :\ C_3^2 (3)=\frac :\ C_4^2 (3)=\frac\ \cdots Note in Step 4, 1 \leq i \leq n for \mathbf(i) . So the terms \mathbf(j) such that d mathbf(3), \mathbf(j)\leq r include \mathbf(3), \mathbf(6), \mathbf(9),\ldots,\mathbf(48), and the total number is 16. At the end of these calculations, we have :\phi^2 (3) = \sum_^\log(C_i^2(3))\approx-1.0982 Then we repeat the above steps for m=3 . First form a sequence of vectors: :\begin \mathbf(1) & = (1) \ u(2) \ u(3) 5 \ 80 \ 89\ \mathbf(2) & = (2) \ u(3) \ u(4) 0 \ 89 \ 85\ \mathbf(3) & = (3) \ u(4) \ u(5) 9 \ 85 \ 80\ \mathbf(4) & = (4) \ u(5) \ u(6) 5 \ 80 \ 89\ &\ \ \vdots \end By calculating distances between vector \mathbf(i), \mathbf(j), 1 \le i \le 49 , we find the vectors satisfying the filtering level have the following characteristic: :d mathbf(i), \mathbf(i+3)0 Therefore, :\ C_1^3 (3)=\frac :\ C_2^3 (3)=\frac :\ C_3^3 (3)=\frac :\ C_4^3 (3)=\frac\ \cdots At the end of these calculations, we have :\phi^3 (3)= \sum_^\log(C_i^3(3))\approx-1.0982 Finally, : \mathrm=\phi^2 (3)-\phi^3 (3)\approx0.000010997 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(U, m, r) -> float: """Approximate_entropy.""" def _maxdist(x_i, x_j): return max( bs(ua - va) for ua, va in zip(x_i, x_j) def _phi(m): x = U[jfor_j_in_range(i,_i_+_m_-_1_+_1).html" ;"title=".html" ;"title="U[j">U[jfor j in range(i, i + m - 1 + 1)">.html" ;"title="U[j">U[jfor j in range(i, i + m - 1 + 1)for i in range(N - m + 1)] C = [ len([1 for x_j in x if _maxdist(x_i, x_j) <= r]) / (N - m + 1.0) for x_i in x ] return (N - m + 1.0) ** (-1) * sum(np.log(C)) N = len(U) return abs(_phi(m + 1) - _phi(m)) Usage example: >>> U = np.array( 5, 80, 89* 17) >>> print(ApEn(U, 2, 3)) 1.0996541105257052e-05 >>> randU = np.random.choice( 5, 80, 89 size=17*3) >>> print(ApEn(randU, 2, 3)) 0.8626664154888908


MATLAB implementation


Fast Approximate Entropy
from MatLab Central


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.


Advantages

The advantages of ApEn include: *Lower computational demand. ApEn can be designed to work for small data samples ( N < 50 points) and can be applied in real time. *Less effect from noise. If data is noisy, the ApEn measure can be compared to the noise level in the data to determine what quality of true information may be present in the data.


Limitations

The ApEn algorithm counts each sequence as matching itself to avoid the occurrence of \log(0) in the calculations. This step might introduce bias in ApEn, which causes ApEn to have two poor properties in practice: # ApEn is heavily dependent on the record length and is uniformly lower than expected for short records. # 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.


Applications

ApEn has been applied to classify
electroencephalography Electroencephalography (EEG) is a method to record an electrogram of the spontaneous electrical activity of the brain. The biosignals detected by EEG have been shown to represent the postsynaptic potentials of pyramidal neurons in the neocortex ...
(EEG) in psychiatric diseases, such as schizophrenia, epilepsy, and addiction.


See also

*
Recurrence quantification analysis Recurrence quantification analysis (RQA) is a method of nonlinear data analysis (cf. chaos theory) for the investigation of dynamical systems. It quantifies the number and duration of recurrences of a dynamical system presented by its phase space tr ...
*
Sample entropy Sample entropy (SampEn) is a modification of approximate entropy (ApEn), used for assessing the complexity of physiological time-series signals, diagnosing diseased states. SampEn has two advantages over ApEn: data length independence and a relative ...


References

{{Reflist Time series Entropy and information Articles with example Python (programming language) code