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.[1] SampEn has two advantages over ApEn: data length independence and a relatively trouble-free implementation. Also, there is a small computational difference: In ApEn, the comparison between the template vector (see below) and the rest of the vectors also includes comparison with itself. This guarantees that probabilities are never zero. Consequently, it is always possible to take a logarithm of probabilities. Because template comparisons with itself lower ApEn values, the signals are interpreted to be more regular than they actually are. These self-matches are not included in SampEn. However, since SampEn makes direct use of the correlation integrals, it is not a real measure of information but an approximation. The foundations and differences with ApEn, as well as a step-by-step tutorial for its application is available at.[2]
There is a multiscale version of SampEn as well, suggested by Costa and others.[3]
Definition
Like approximate entropy (ApEn), Sample entropy (SampEn) is a measure of complexity.[1] But it does not include self-similar patterns as ApEn does. For a given embedding dimension , tolerance and number of data points , SampEn is the negative natural logarithm of the probability that if two sets of simultaneous data points of length have distance then two sets of simultaneous data points of length also have distance . And we represent it by (or by including sampling time ).
Now assume we have a time-series data set of length with a constant time interval . We define a template vector of length , such that and the distance function (i≠j) is to be the Chebyshev distance (but it could be any distance function, including Euclidean distance). We define the sample entropy to be
Where
= number of template vector pairs having
= number of template vector pairs having
It is clear from the definition that will always have a value smaller or equal to . Therefore, will be always either be zero or positive value. A smaller value of also indicates more self-similarity in data set or less noise.
Generally we take the value of to be and the value of to be . Where std stands for standard deviation which should be taken over a very large dataset. For instance, the r value of 6 ms is appropriate for sample entropy calculations of heart rate intervals, since this corresponds to for a very large population.
Multiscale SampEn
The definition mentioned above is a special case of multi scale sampEn with ,where is called skipping parameter. In multiscale SampEn template vectors are defined with a certain interval between its elements, specified by the value of . And modified template vector is defined as and sampEn can be written as And we calculate and like before.
Implementation
Sample entropy can be implemented easily in many different programming languages. Below lies a vectorized example written in Python.
1import numpy as np
2
3def sampen(L, m, r):
4 N = len(L)
5 B = 0.0
6 A = 0.0
7
8
9 # Split time series and save all templates of length m
10 xmi = np.array([L[i : i + m] for i in range(N - m)])
11 xmj = np.array([L[i : i + m] for i in range(N - m + 1)])
12
13 # Save all matches minus the self-match, compute B
14 B = np.sum([np.sum(np.abs(xmii - xmj).max(axis=1) <= r) - 1 for xmii in xmi])
15
16 # Similar for computing A
17 m += 1
18 xm = np.array([L[i : i + m] for i in range(N - m + 1)])
19
20 A = np.sum([np.sum(np.abs(xmi - xm).max(axis=1) <= r) - 1 for xmi in xm])
21
22 # Return SampEn
23 return -np.log(A / B)
An example written in other languages can be found:
References
- Richman, JS; Moorman, JR (2000). "Physiological time-series analysis using approximate entropy and sample entropy". American Journal of Physiology. Heart and Circulatory Physiology. 278 (6): H2039–49. doi:10.1152/ajpheart.2000.278.6.H2039. PMID 10843903.
- Delgado-Bonal, Alfonso; Marshak, Alexander (June 2019). "Approximate Entropy and Sample Entropy: A Comprehensive Tutorial". Entropy. 21 (6): 541. doi:10.3390/e21060541.
- Costa, Madalena; Goldberger, Ary; Peng, C.-K. (2005). "Multiscale entropy analysis of biological signals". Physical Review E. 71 (2): 021906. doi:10.1103/PhysRevE.71.021906. PMID 15783351.