Filter löschen
Filter löschen

How to get the rgression line tangent to the curve

2 Ansichten (letzte 30 Tage)
Mahesh
Mahesh am 6 Jun. 2015
Kommentiert: Star Strider am 7 Jun. 2015
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 Kommentare
Image Analyst
Image Analyst am 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 am 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

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Star Strider
Star Strider am 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 Kommentare
Mahesh
Mahesh am 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.
Star Strider
Star Strider am 7 Jun. 2015
My pleasure.
I will see what I can find.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Descriptive Statistics finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by