How to get the rgression line tangent to the curve

1 visualización (últimos 30 días)
Mahesh
Mahesh el 6 de Jun. de 2015
Comentada: Star Strider el 7 de Jun. de 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 comentarios
Image Analyst
Image Analyst el 6 de Jun. de 2015
You forgot to give us x. Make it easy for us to run your code and help you, not hard.
Mahesh
Mahesh el 7 de Jun. de 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

Iniciar sesión para comentar.

Respuesta aceptada

Star Strider
Star Strider el 6 de Jun. de 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 comentarios
Mahesh
Mahesh el 7 de Jun. de 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 el 7 de Jun. de 2015
My pleasure.
I will see what I can find.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Linear and Nonlinear Regression en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by