- Your upper and lower bounds must be specified as length 4 vectors
- Your unknowns x(i) and their initial guesses k(i) cannot be complex numbers
- To derive a good initial guess, you might start by fitting the log of your model equation,
Lsqcurvefit to gamma variate function
4 ビュー (過去 30 日間)
古いコメントを表示
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
0 件のコメント
回答 (1 件)
Matt J
2014 年 3 月 5 日
編集済み: Matt J
2014 年 3 月 5 日
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.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrix Computations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!