Re: Curve Fitting
- From: John D'Errico <woodchips@xxxxxxxxxxxxxxxx>
- Date: Mon, 10 Apr 2006 12:19:52 GMT
In article <ef2fc74.5@xxxxxxxxxxxxxxxx>, "Kah-Kheng Khoo" <kahkheng_khoo@xxxxxxxxxxxxxxxxx> wrote:
Its probable that you will be unhappy with the
results from many nonlinear fits. Your curves do
not really fit the shape of most common "s" surves.
Why not? These curves (at least some of them)
go through a very sharp transition, with a sharp
shoulder, but then have soft tails. So anything
like a logistic curve, if it goes through that
very sharp transition, will be absolutely flat
in its tails. A trick is to use an extra term to
soften those tails. I picked one of the curves
y3(x) and built a model with an arbitrarily
chosen logistic model. It fit reasonably well,
although I cannot promise as much for some of
your other curves. Here are models for each
of the data sets
inline1(x) = 1./(1+exp(-x))
y1(x) = 0.77437 + -0.00095003*x + ...
-0.61227*inline1((x - 0.30179)/0.56219)
y2(x) = 0.74384 + -0.00096337*x + ...
-0.58398*inline1((x - 0.35022)/0.54256);
y3(x) = 0.73301 + -0.0011195*x + ...
-0.033095*inline1((x - 6.8642)/6.5064)
y4(x) = 0.87616 + -0.00020269*x + ...
-0.093307*inline1((x - 6.9592)/3.5474)
This last curve fits very poorly, due to the
fact that it has a very asymmetrical shape from
the toe to the shoulder. Again, most simple
models will fail to represent this curve type
well.
Why do you need an explicit functional form?
A spline model can be used just as well much
of the time. And if you are choosing arbitrary
terms in nonlinear models, its hard to justify
them as seriously better, especially when the
fit is poor.
John
John,
Thanks for your reply. I've tried out some of the curves and they do
fit very nicely. I have a couple of questions though..
1. How did you derive to use the exp in function? and
2. If I wanted to derive the equation as a function of y, how would
the equation look like?
Again, thanks in advance for your help.
I used my own nonlinear curvefitting toolbox, written
10+ years ago. I lets me add or delete terms for a model
quickly, so finding and fitting a model is usually just
a matter of a few tries. Since I've never published that
code, this will do it nicely too:
f = {1, @(c,x) x, @(c,x) 1./(1+exp(-(x-c(1))/c(2)))}
[inlp,ilp]=fminspleas(f,[0,1],x,y1,[],[],optimset('maxiter',1000,'maxfuneval',1000))
inlp =
0.30211 0.56003
ilp =
0.77416
-0.00095542
-0.61187
It uses my fminspleas, from the file exchange.
http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=10093&objectType=FILE
Regardless of how you build the model, a nonlinear
model of this form will not be simply invertible,
unless the symbolic toolbox can find some form that
uses the Lambert W function.
If your goal is to find an inverse function, an
interpolating spline may still be the simplest
solution, unless you are worried about any noise
in your data. I'd strongly recommend pchip for
this type of curve shape.
(I was going to suggest ppcreate, by Duane Hanselman
on the file exchange, but it appears to be missing
its pchip module. I've notified Duane, so I'll bet
its fixed in a few days.)
You can still use pchip to solve this problem though.
pp = pchip(y1,x);
ppval(pp,.5)
ans =
0.10223
ppval(pp,.1)
ans =
54.076
John
--
The best material model of a cat is another, or preferably the same, cat.
A. Rosenblueth, Philosophy of Science, 1945
Those who can't laugh at themselves leave the job to others.
Anonymous
.
- References:
- Curve Fitting
- From: Kah Kheng Khoo
- Re: Curve Fitting
- From: John D'Errico
- Re: Curve Fitting
- From: Kah Kheng Khoo
- Re: Curve Fitting
- From: John D'Errico
- Re: Curve Fitting
- From: Kah-Kheng Khoo
- Curve Fitting
- Prev by Date: Re: Trivial question, strings
- Next by Date: Optimization Isothermal CSTR with GA
- Previous by thread: Re: Curve Fitting
- Next by thread: Re: Curve Fitting
- Index(es):
Relevant Pages
|