How can I find the values for three parameters, (a, b, c), using a minimum sum of squares criterion?
Show older comments
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.
Answers (2)
Walter Roberson
on 19 Dec 2013
0 votes
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
on 19 Dec 2013
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 Comment
Walter Roberson
on 19 Dec 2013
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.
Categories
Find more on Get Started with Curve Fitting Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!