How to get the rgression line tangent to the curve

1 次查看(过去 30 天)
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 个评论
Image Analyst
Image Analyst 2015-6-6
You forgot to give us x. Make it easy for us to run your code and help you, not hard.
Mahesh
Mahesh 2015-6-7
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

请先登录,再进行评论。

采纳的回答

Star Strider
Star Strider 2015-6-6
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 个评论
Mahesh
Mahesh 2015-6-7
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Descriptive Statistics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by