How to get the rgression line tangent to the curve

2 views (last 30 days)
I have a sample code which allows us to compute the correlation dimension as follows.
function [obj] = correldim(X)
N = numel(X);
arrayDist = zeros(N, N);
for i = 1:N
x1 = X(i);
for j = 1:N
x2 = X(j);
arrayDist(i,j) = abs(x1-x2);
end
end
Nr = 20;
r = linspace(0.0005, 0.015, Nr);
for k = 1:numel(r);
countk = find(arrayDist >= r(k));
cr(k) = numel(countk);
end
logr = log10(r);
logcd = log10(cr);
hold on
plot(logr, logcd)
[dimc, se]= polyfit(logr, logcd, 1);
f = polyval(dimc,logr);
plot(logr, f)
hold off
xlabel('log\epsilon');
ylabel('logC(\epsilon)');obj.cd = dimc(1);
box on
end
I noticed that while plotting the regression line using ployfit with order 1, the line crosses the curve. It looks to me the coefficient of regression line is not feasible. Could please help me how to do in exact way. I have attached the figure and code for your reference.
Thanks
Mahesh
  2 Comments
Image Analyst
Image Analyst on 6 Jun 2015
You forgot to give us x. Make it easy for us to run your code and help you, not hard.
Mahesh
Mahesh on 7 Jun 2015
Thank you for your response
X = load('Data_1.txt');
X = X/sum(X);
[obj] = correldim(X)
I hope it works for you to help me. Thank you for your kind cooperation

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 6 Jun 2015
If I remember correctly (and from the Wikipedia article on Correlation dimension), you don’t need to plot the log-log regression line.
You are doing the regression to estimate the correlation dimension, and the correlation dimension is the slope of the log-log regression, or dimc(1).
  2 Comments
Mahesh
Mahesh on 7 Jun 2015
If so, that's fine. But I am seeking for generic one. If you have some clues, kindly let me know. Thanks for your response.

Sign in to comment.

More Answers (0)

Categories

Find more on Descriptive Statistics in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!