[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Non-Linear implicit Curve Fitting
From: |
Damian Harty |
Subject: |
RE: Non-Linear implicit Curve Fitting |
Date: |
Mon, 18 Nov 2013 10:04:07 +0000 |
> >Good Day
> >
> >I have two data sets.x and F that has about 10000 points each.
> >
> >I also have the following equation:
> >F = C_CV .* alpha.^( x - 1) .* sqrt(a .* F.^2+ b * F + c)
> >
> >I want to fit that equation on the data above. everything is unknown
> >as specified.
> >Any idea on how to accomplish this?
> >
> >I tried a few methods put nothing gave me a proper fit
I've had great results with Nelder Mead methods - fminsearch in Matlab and
nelder_mead_min in Octave. There are some good examples here:
http://www.cogsci.ucsd.edu/~desa/109/nonlinnotes.html
It's instructive using the animation of the fit to start with because in the
(unlikely) event of the fit failing to converge, you can use it to suggest more
plausible start values. Use the lower part of the tutorial, the top is somewhat
trivial. I fitted datasets of about that size without any real difficulty, and
quite quickly.
An important hint I was given was to manipulate the functions so that all your
unknowns are within 1 or 2 orders of magnitude. The Nelder Mead method doesn't
like it if one of your variables is 9,872 and another one is 4.26E-5. It's easy
to do but you'll never guess you need to do it unless someone tells you. Oh,
and don't start with all zeros. Nelder Mead Downhill Simplex is something of a
donkey of a fitting engine - a reliable plodder that almost always gets there
regardless of how you load it up.
I didn't find the syntax of the call very instinctive but using the above
tutorials I did what I needed to do.
My example was something like this:
initial_BCDE_guess=[0.5; 0.5; 0.5; 0.5];
estimated_BCDE = nelder_mead_min(test_fit_function4(BCDE,X,Y_DASH),ctl)
In case it's not obvious, X is the ordinate dataset (no need for them to be
monotonic), Y_DASH is the data I'm wanting to fit - the same size as X,
obviously. The function test_fit_function_4 was pretty simple:
function err = test_fit_function4(par,input,data_to_fit)
Z = par(3)*sin( par(2)*atan(par(1)*(1-par(4))*input +
par(4)*atan(par(1)*input)) );
err = norm(Z-data_to_fit);
My function was quite non-linear, as you can see. I'm not guaranteeing this
code works as is - I've snipped and pasted it so it's untested - but the logic
should get you there if you persevere a bit.
I've since used it to fit a decaying sine wave to noisy test data and got good
results from that, too.
Damian
________________________________
CONFIDENTIAL:
The information contained in this email communication is confidential
information intended only for the use of the addressee. Unauthorized use,
disclosure or copying of this communication is strictly prohibited and may be
unlawful. If you have received this communication in error, please notify us
immediately by return email and destroy all copies of this communication,
including all attachments.