Lsqcurvefit to gamma variate function

조회 수: 5 (최근 30일)
Maria
Maria 2014년 3월 5일
편집: Matt J 2014년 3월 5일
Hi,
I have been trying to use lsqcurvefit to fit to a gamma variate function without much luck. It appears to be very sensitive to starting conditions. I have tried altering the lower and upper bounds carefully but it still appears to fail delivering a good fit. What am I doing wrong? Any help is appreciated.
Maria
% startparams
k(1)=26.5146 + 5i;
k(2)=48.5670 + 0.0000000i;
k(3)=-0.12 - 0.1300i; % VERY sensitive
k(4)=38.7744e+01 + 19.2626e+02i;
a = lsqcurvefit(@gma_var,k,t,y,2,2000);
b= lsqcurvefit(@gma_var,k,t,y2,2,2000);
Func= a(1)*((t-a(2)).^a(3)).*exp(-(t-a(2))/a(4));
Func_t= b(1)*((t-b(2)).^b(3)).*exp(-(t-b(2))/b(4));
% gamma variate function
function out=gma_var(x,xdata)
F= x(1)*((xdata-x(2)).^x(3)).*exp(-(xdata-x(2))/x(4));
out=F;
end

답변 (1개)

Matt J
Matt J 2014년 3월 5일
편집: Matt J 2014년 3월 5일
  1. Your upper and lower bounds must be specified as length 4 vectors
  2. Your unknowns x(i) and their initial guesses k(i) cannot be complex numbers
  3. To derive a good initial guess, you might start by fitting the log of your model equation,
logF = z(1)+z(3)*log(xdata-z(2)) - z(4)*(xdata + z(2))
where I've made the change of variables,
z(1)=log(x(1)),
z(2)=x(2),
z(3)=x(3),
z(4)=1/x(4).
This equation is linear w.r.t all but z(2). FMINSPLEAS ( available here ) would probably do a good job with it.

카테고리

Help CenterFile Exchange에서 Matrix Computations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by