Code covered by the BSD License  

Highlights from
Sample Entropy

4.4 | 8 ratings Rate this file 104 Downloads (last 30 days) File Size: 1.73 KB File ID: #35784
image thumbnail

Sample Entropy


Kijoon Lee


This short code calculates the sample entropy (SampEn) of a given time series data.

| Watch this File

File Information

SampEn is a measure of complexity that can be easily applied to any type of time series data, including physiological data such as heart rate variability and EEG data.

SampEn is conceptually similar to approximate entropy (ApEn), but has following differences:

1) SampEn does not count self-matching. The possible trouble of having log(0) is avoided by taking logarithm at the latest step.
2) SampEn does not depend on the datasize as much as ApEn does. The comparison is shown in the graph above. This property makes it amenable to applications with relatively short data size.

This code uses the same vectorisation technique as in Fast Approximate Entropy, another submission from the same author.


Fast Approximate Entropy inspired this file.

This file inspired Sample Entropy.

MATLAB release MATLAB 7.13 (R2011b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (11)
06 Nov 2014 Hesam


I wrote .c file which is more than two times faster than .m file.

09 Jul 2014 Awadhesh Ranjan

Awadhesh Ranjan

18 Feb 2014 zhou wei

zhou wei

08 Nov 2013 Liang ZOU

Liang ZOU

17 Apr 2013 miss khatimah

miss khatimah

19 Mar 2013 Alexander


Regard my previous one star rating as a mistake. Apparently mathworks immediately submitted the rating when I clicked on one of the stars.

Comment only
19 Mar 2013 Alexander


19 Mar 2013 Alexander


20 Jul 2012 Kavitha


May I know what is the first argument dim in the function? I want to pass on-channel EEG signal 500 samples (with sampling frequency 128 Hz) to the program to calculate entropy? Also please advice me how to use 'r'?

Comment only
28 Mar 2012 Hugh


oops... I found that function rand is uniform distribution, not white noise. Your code is right!

28 Mar 2012 Hugh


I have a question.
It is known that if the input data is white noise, SampEn will decrease as tau increases. However, I tried this code with input rand(1,2000) and different tau, and it seems that SampEn will have similar values no matter what tau. What's wrong with this?

Comment only

Contact us