non-linear fitting with min(sse) of x
3 views (last 30 days)
Show older comments
Hi there, I have X1, X2 and Y1 data set and a function of x=f(y,B), but not y=g(x,B), where B is a vector of parameters. Unfortunately, the inverse function of f can't be solved analytically. So I am stuck with x=f(y,B).
The problem is I want to estimate the parameter values of the function, based on X1 and Y1, so that I can use it to estimate Y2 from X2, numerically.
Is it possible at all to estimate parameter values based on SSE regarding Y1, and not X1? NonLinearModel.fit and nlinfit do not seem to offer the option.
Cheers, PA
3 Comments
Accepted Answer
Matt J
on 23 Nov 2012
Edited: Matt J
on 24 Nov 2012
If you have the Optimization Toolbox, maybe you can express g(x,B) in the following way and pass it to your favorite solver,
g=@(x,B) fsolve(@(y) f(y,B)-x , y0);
You could also generalize this by making the initial guess y0 a more general function of (x,B), if you know a good custom initialization scheme.
4 Comments
Matt J
on 24 Nov 2012
Edited: Matt J
on 24 Nov 2012
No, nothing I've given here has anything to do with solving for Y2 or assumes anything is given. It's just a way of computing the inverse g(x,B) for any pair (x,B) without knowing its explicit analytical form. I illustrate below with a simple function f(y,B)= y.^2 +B and compare it with its known analytical inverse gtrue(x,B)=sqrt(x-B). Instead of FSOLVE though, I use FMINSEARCH because I don't have the Optimization Toolbox.
f=@(y,B) y.^2+B;
y0=@(x,B) max(B,sqrt(abs(x))); %A heuristic initializer
g=@(x,B) fminsearch(@(y) (f(y,B)-x).^2, y0(x,B));
gtrue=@(x,B) sqrt(x-B);
We can now check whether g(x,B) and gtrue(x,B) give the same approximate values for different pairs of inputs x and B:
>> gtrue(1,1), g(1,1)
ans =
0
ans =
-8.8818e-16
>> gtrue(2,1), g(2,1)
ans =
1
ans =
1.0000
>> gtrue(5,3), g(5,3)
ans =
1.4142
ans =
1.4142
>> gtrue(15,5), g(15,5)
ans =
3.1623
ans =
3.1623
More Answers (0)
See Also
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!