Problems with MLE method and curve fitting!
4 views (last 30 days)
Hi everyone, I hope someone can help me!
How can I estimate the parameters of a function (using an anonymous function) with the maximum likelihood method? I've seen several things on the internet (like mle, fminsearch) but nobody gives me the parameter values!
Example I have:
eq = fittype (@ (a, b, c, x) a * x. ^ 2 + b * x + c);
how do i get the values of a, b and c with the MLE method?
Thanks a lot to everyone!
Rishabh Mishra on 22 Jan 2021
Based on my understanding, you can use 'polyfitn' function to estimate the parameters a, b, c. For this purpose, you require a set of values of 'x' as double array and the corresponding values of function (a*x.^2 + b*x + c) stored in another double array say 'y'. Use the code below to estimate the co-efficient values for the function (a*x.^2 + b*x + c).
% assuming 'x' & 'y' are double arrays
% 'y' stores the function value corresponding to each element of 'x'
% 'n' stores degree of the function
n = 2;
p = polyfitn(x,y,n);
The values p.Coefficients(1), p.Coefficients(2) & p.Coefficients(3) correspond to estimated values of coefficients a, b & c respectively.
Hope this helps.