File Exchange

## Fast Approximate Entropy

version 1.1.0.0 (25.5 KB) by
This function calculates Approximate Entropy (ApEn) of a time series data in a very efficient way.

Updated 20 Mar 2012

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.

### Cite As

Kijoon Lee (2021). Fast Approximate Entropy (https://www.mathworks.com/matlabcentral/fileexchange/32427-fast-approximate-entropy), MATLAB Central File Exchange. Retrieved .

jianqing luo

hello,
How can this be applied on the Image.

Sania Zahan

Dear Kijoon Lee
Thanks for your code. But I am having some problem with the output. ApEn is supposed to give lower value for more repetitive pattern but I am getting the opposite. I have two types of brain signal one is normal (more unpredictable and getting lower ApEn) and another is epileptic (more predictable and getting higher ApEn).

Chee Wan Ting

I am interested in this method for signal analysis. However, when I try to set the data matrix, it shows dimension mismatch. My data file is 7500x1 double. May I ask if how should I configure the code for
for i = 1:m
dataMat(i,:) = data(i:N-m+i);
end
where N = 8000

smach kim

Dear SUBHAMITRA PATRA

%% Input data

a=0;
a=a';
data=a;
dim = 2;
tau = 1;
N = 1000;
t = 0.001*(1:N);
r=0.25;

and the it show like this:

>> ApEn(2,0.25,data,1);
Undefined function or variable 'ApEn'.

Did you mean:
>> open(2,0.25,data,1);

i try it many time but it still unknown ......can you guide any ways ?

RP

RP

Dear Sir,

I have tried this code But getting the following error at the beginning stage.

apen = ApEn( dim, r, data, tau )
Undefined function or variable 'dim'.
Did you mean:
>> apen = open( sim, r, date, tau )
if tau > 1, data = downsample(entropymeasurement, tau); end
Command syntax error see SIM command for details
Undefined function or variable 'tau'.

Therefore, I have one query that before running this code, one needs to declare the particular series as time series and then can be able to run the code.

If not, please mention what is the starting procedures or steps (after the importing the data series) before running this code?

A kind help is highly appreciated.

Shamus Smith

Sahar Soussa

shishir

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

Thank You

Thank you! Will read the paper later.

John

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.

olga

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?

Céldor

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:
doi:10.1016/j.ymssp.2006.02.009

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

Kijoon Lee

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.

-Kijoon

Céldor

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

afas

afas

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