View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Fast Approximate Entropy

5.0 | 5 ratings Rate this file 63 Downloads (last 30 days) File Size: 25.5 KB File ID: #32427 Version: 1.1
image thumbnail

Fast Approximate Entropy


Kijoon Lee (view profile)


04 Aug 2011 (Updated )

This function calculates Approximate Entropy (ApEn) of a time series data in a very efficient way.

| Watch this File

File Information

Approximate Entropy (ApEn) is a popular tool in analysing the complexity of time series data especially in clinical research.

This function is a very simple and efficient implementation of ApEn, based on vectorization concept that improves speed tremendously over for-loop implementation.

It also contains a test code (foo.m) for generating a plot of ApEn of different simulated time series data, to help understand the usage. The test code generates a plot similar to that appearing in Ki H. Chon's 2009 paper in IEEE Eng in Med Biol, that discusses what r value we should use.


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 (10)
24 Nov 2016 Sahar Soussa

06 Jul 2015 shishir

Dear sir,
How can this be applied on the Image.

Thank You

Comment only
10 Jun 2015 Dennis A. Dean, II, Ph.D.

Thank you! Will read the paper later.

06 May 2013 John

John (view profile)

I am interested in using this method to calculate approximate entropy for a boids model.
Can anyone suggest how I can complete the calculation for a specified number of boids in two dimensional space?

(I have txt files with lists of integer values for x and y co-ordinates.

Comment only
04 Oct 2012 olga

olga (view profile)

I have been working with your program and testing it. I am a bit confused with your implementation. It is possible to get negative ApEn values, which make no sense to me. Could you please explain this to me. Also, it seems that each consecutive pattern is subtracted not only from the "future" coming patterns but also from the "past" or preceding patterns, which, in your implementation, would count the same matching pattern combination twice (you are finding and absolute value of the difference between two patterns). How does that work?

Comment only
19 May 2012 Céldor

Céldor (view profile)

Dear Kijoon,

Thanks for details regarding the paper and the brief explanation on parameters. I have managed to find out a little bit about them from another paper that you may also be interested in:

It provides some investigation and then considerations in terms of efficiency of App Entr. when it comes to decide about values of parameters. It's been very useful to me.

Best regards

Comment only
19 May 2012 Kijoon Lee

Kijoon Lee (view profile)

Dear Celdor,

The DOI of the paper is 10.1109/MEMB.2009.934629 so you can find it easily.

The first argument, dim, means embedded dimension. That is the length of the sequence to be compared, and typical value for that is 2 or 3.
The second argument, r, is the tolerance for matching. In other words, a pair of values whose difference is smaller than r is considered matching. Typically 0.2*std is used (std means standard deviation of the whole timeseries data), but this paper by Chon suggests that r value should be chosen carefully, and one should look for r value that maximizes the ApEn.

Hope it clears some of your doubts.


Comment only
18 May 2012 Céldor

Céldor (view profile)

Hi Kijoon,

I am very grateful for this file that just saves a lot of time. However, could you please if this is not a problem to give some details of the paper you have mentioned? I am not sure if I understood the meaning of the first and the second argument of your function.

Many thanks

11 Oct 2011 afas

afas (view profile)

11 Oct 2011 afas

afas (view profile)

20 Mar 2012 1.1

The new version (Ver 1) has corrected a minor error in the definition of ApEn, and included another input argument tau for multi-scale ApEn calculation. See inside for details.

Contact us