Difficulty in understanding correlation dimension I am trying to implement the  Grassberger Procaccia algorithm. I have got stuck in how to find the summation of the correlation integral. The following code computes the correlation dimension in the polyfit command. I cannot understand how this command is finding the dimension since the derivative or slope of the correlation integral gives the correlation dimension. So, where is the derivative being calculated? I know that I am asking to understand the code but I am having a tough time to understand in which variable the correlation sum ie Summation of log(correlation sum) is being calculated. I shall be really greatful for an explanation. Thank you.
 A: If you have a look at the Scholarpedia article you linked to, you will find that the Grassberger–Procaccia algorithm is not concerned with the correlation integral, but with the correlation sum, which is an unbiased estimator of the theoretical quantity. The correlation sum $\hat C(r)$ is defined as "the fraction of pairs whose distance is smaller than $r$".
It appears that in your code the value of the correlation sum is supposed to be stored in count and then ratio(2, ·) and $r$ in epsilon and then ratio(1, ·). I can't identify any point where the count is transformed into a ratio though.
As the comment in the code states, the stored values are not used to compute the correlation dimension directly, but are stored "for later graphical analysis with Excel". Despite the "Excel" part, the last two lines actually plot ratio in a log-log plot and fit a line. The slope of this fitted line would be a – very rough! – estimate of the correlation dimension.
The reason why the code does not directly estimate the dimension is also explained in the Scholarpedia article: The dimension is defined as $D=\lim_{r\to 0} {{\log C(r)}\over {\log r}}$, and translating this into data analysis "involves an extrapolation to a limit where the statistics is severely undersampled". To get a decent estimate, you have to actually look at the plot and find out whether and where the expected scaling behavior is present, and then use a line fit to estimate the dimension from that part.
The code you use appears to me to be something of a quick hack. In order to understand the Grassberger–Procaccia algorithm I'd recommend you get rid of that code, read carefully the Scholarpedia article, and try to implement it yourself – it's really not that complicated. If you need more help, I can strongly recommend the book Nonlinear time series analysis by Kantz & Schreiber, cited in the Scholarpedia article, which discusses in detail the practical problems in estimating this and other nonlinear measures from data.
