File Exchange

image thumbnail

Approximate Entropy

version (1.93 KB) by Avinash Parnandi
This function computes approximate entropy of a data series.


Updated 31 Jan 2010

View License

Approximate Entropy is a measure of complexity. It quantifies the unpredictability of fluctuations in a time series.
This is a function for computing approx entropy. To run it you need to provide the data stream, the window size and distance measure for comparison.

Cite As

Avinash Parnandi (2021). Approximate Entropy (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (18)

小彩 王

maybe there is a mistake cause it's more like the way to calculate sample entropy

jianqing luo

How to calculate the two-dimensional approximate entropy?

Dharshini VK

how to insert the my datas that i stored in excel sheets...i need fast repy pls

samuel arpagaus

I think there is a mistake since the "log-function" should be taken before taking the sum.

samuel arpagaus

I think there is an mistake, since your division for "N" is made twice....

Bora Eryilmaz

Please note that the R2018a version of MATLAB includes an approximateEntropy command in the Predictive Maintenance Toolbox. See the documentation for details:

piyush varshney

what is the similiarity measure of data set and how is calculated?

matlab c


why i got negative value of approximate entropy? am i wrong


Where do I download the algorithm? thanks

D Dan

I know it's basic but how and what do I put in 'a'. meaning how do I write the 'data set' or "data vector" in matlab (very new to all of this)

Thanks :-)

xiuli chai


William Rose

I agree with Sanantha Raj's question.
Pincus defines ApEn in PNAS, 1991, with equations 1, 6, and 10. Equation 6 indicates that one should take the sum of the logs, rather than the log of the sum. But the equation used in approx_entropy.m is consistent with the equation given by Moody at Can you explain the discrepancy?

Santhana Raj

It looks like you are computing the Sample Entropy rather than the Approximate entropy.

I am new to this area and this is what I feel in my first observation. Correct me if I am wrong.

I say it is algorithm of Sample Entropy because you take logarithm of the ratio at the end rather than at the counter itself before calculation Correlation.


That should have said 'boids'.

Shinichi Amano

Shinichi Amano

I also used this code. Thanks, it helps me a lot.

Time needed to calculate apen is depending on the data size, obviously.
I used this code to calculate entropy for 7200 datapoints. It took me about 10 min to get a result. you have to wait for a while.

george ts

Firstly your algorithm works very well on a windows machine,and i have to thank you because you help me a lot...
Secondly, i have one problem when i run your algorithm and if you could help me i wll appreciate it a lot..Well, when i try to run your algorithm,using a multi-sample-signal it does not provide any results(eg [apen] = approx_entropy(2000,0.5,a)).It only shows that it is in busy mode for a long time so i have to exit from matlab.On the contrary,when I am trying to run it using an one-sample-signal(eg "sine") with 10 samples,it provides me results.So,I believe that the algorithm's disfunction depends on the amount of the samples I use when I am running it.
Thank you for your time!!

MATLAB Release Compatibility
Created with R2007a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired: Fast Approximate Entropy

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!