Example 1: Sample Entropy

Import a signal of normally distributed random numbers [mean = 0; SD = 1], and calculate the sample entropy for each embedding dimension (m) from 0 to 4.

X = ExampleData("gaussian");
Samp, _ = SampEn(X, m = 4);
5-element Vector{Float64}:
 2.178923612371957
 2.175742327787873
 2.181969567351662
 2.2209839754321417
 2.1755667174542923

Select the last value to get the sample entropy for m = 4.

Samp[end]
2.1755667174542923

Calculate the sample entropy for each embedding dimension (m) from 0 to 4 with a time delay (tau) of 2 samples.

Samp, Phi1, Phi2 = SampEn(X, m = 4, tau = 2)
([2.178923612371957, 2.183323250654987, 2.188041075511569, 2.189184333017654, 2.1440802180581136], [1.414258e6, 159224.0, 17843.0, 1998.0, 234.0], [1.24975e7, 1.413233e6, 159119.0, 17838.0, 1997.0])

Import a signal of uniformly distributed random numbers in the range [-1, 1] and calculate the sample entropy for an embedding dimension (m) of 5, a time delay of 2, and a threshold radius of 0.075. Return the conditional probability (Vcp) and the number of overlapping matching vector pairs of lengths m+1 (Ka) and m (Kb), respectively.

Samp, _, _, Vcp_Ka_Kb = SampEn(X, m = 5, tau = 2, r = 0.075, Vcp = true)
Vcp, Ka, Kb = Vcp_Ka_Kb
Vcp = 0.00018629728228987074
Ka = 92
Kb = 3943