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.
There is a multiscale version of SampEn as well, suggested by Costa and others.[2]
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 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 of length
= number of template vector pairs having of length
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. An example written in Matlab can be found here. An example written for R can be found here.
Python
import numpy as np
def SampEn(U, m, r):
def _maxdist(x_i, x_j):
result = max([abs(ua - va) for ua, va in zip(x_i, x_j)])
return result
def _phi(m):
x = [[U[j] for j in range(i, i + m - 1 + 1)] for i in range(N - m + 1)]
C = [len([1 for j in range(len(x)) if i != j and _maxdist(x[i], x[j]) <= r]) for i in range(len(x))]
return sum(C)
N = len(U)
return -np.log(_phi(m+1) / _phi(m))
References
- ^ a b 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.
- ^ Costa, Madalena; Goldberger, Ary; Peng, C.-K. (2005). "Multiscale entropy analysis of biological signals". Physical Review E. 71 (2). doi:10.1103/PhysRevE.71.021906.