MATLAB: Least square curve fit for function: y = a*x^b*(1-x)^c

least square curve fit

For function like y = a*x^b*(1-x)^c, how can I use the least square curve fit feature to find out the coefficient a, b and c?

Best Answer

Star is simply wrong here. In general it is perfectly possible to estimate those parameters. It IS possible however that you may have difficulty. Not all problems are trivial to solve.
Image analyst is also correct that a simple solution is to use a linear least squares, as applied to a transformation of the problem. I would suggest that you cannot use polyfit though, since polyfit can only handle a single variable problem. Thus,
log(y) = log(a) + b*log(x) + c*log(1-x)
a is unknown, so log(a) is just as much of an unknown. So the model can be written as
log(y) = d + b*log(x) + c*log(1-x)
where
d = log(a)
In the above model, log(x) and log(1-x) must be viewed as different variables, although they are not uncorrelated variables. So call
u = log(x)
v = log(1-x)
Then the model becomes even more simply recognizable as
log(y) = d + b*u + c*v
With variables u and v, this model is simply seen as a linear regression model, with two independent variables. We can estimate the parameters (assuming a column vector x) as
dbc = [ones(size(x)),log(x),log(1-x)]\log(y);
a = exp(dbc(1));
b = dbc(2);
c = dbc(3);
You could also have used my polyfitn (found on the file exchange) to perform the estimation.
Given those estimates of a,b,c, we could now use them as starting values for a tool like the curve fitting toolbox.