How can I find the values for three parameters, (a, b, c), using a minimum sum of squares criterion?
이전 댓글 표시
Consider the following functional form
y(x) = a*x^b*(1-x)^c
for 0 < x < 1 and 0 otherwise. Using the following data
x
0.2675 0.4135 0.1368 0.1688 0.8978 0.9105 0.5677 0.1038 0.2613 0.3678 0.7891 0.0639 0.0887 0.2021 0.6342 0.7086 0.633 0.4558 0.5423 0.3167 0.7202 0.2201 0.6681 0.2152 0.3816
y
27.82 24.25 15.73 21.43 0.62 0.01 11.55 11.74 27 26.31 1.07 6.62 10.19 24.19 6.84 3.97 7.23 20.32 14.53 28.61 3.01 25.54 5.36 24.36 25.21
How can I set up the code? I believe I have to use fmincon but I am confused any help would be appreciated.
답변 (2개)
Walter Roberson
2013년 12월 19일
0 개 추천
Why not use one of the least squares fitting functions? http://www.mathworks.com/help/optim/ug/least-squares-model-fitting-algorithms.html
Andrei Bobrov
2013년 12월 19일
Example to answer Walter:
yfun = @(x,c)c(1)*x.^c(2).*(1-x).^c(3);
lny = log(y);
c1 = [ones(size(lny)),log(x),log(1-x)]\lny;
c = [exp(c1(1));c1(2:end)]; % your coefficients - solution
[~,ii] = sort(x);
plot(x(ii),[y(ii),yfun(x(ii),c)]);
댓글 수: 1
Walter Roberson
2013년 12월 19일
This does a least-squared fit on the log of the values, rather than a least-squared fit on the values themselves. The weighting of the differences changes non-linearly.
카테고리
도움말 센터 및 File Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!