Re: curve fitting using self-defined function
- From: Peter Perkins <Peter.PerkinsRemoveThis@xxxxxxxxxxxxx>
- Date: Fri, 07 Sep 2007 08:51:44 -0400
Richeng Zheng wrote:
Hi guys,
My professor and I are having a question about fitting a set of data using a self-defined function, ex. fittype = a* ( x - 43 ) ^ b + c, using the fit function. However, the confusion comes when the function returned way-off values for the parameters, a, b and c, and thus the fitting function; the returned fitting function with the parameters are not even close to the source curve. In addition, what is very surprising is that sometimes it even generated different sets of values for the parameters when the same source data was repeatedly inputed. Anyone knows any solution to accurately fit a data with a user defined function. Thank alot in advance guys.
I think what you're running into is this (from the fit reference page in the doc):
"For some nonlinear library models (rational and Weibull), and all custom
nonlinear models, default initial values for coefficients are selected uniformly
at random from the interval (0,1). As a result, multiple fits using the same
data and model may lead to different fitted coefficients. To avoid this, initial
values for coefficients can be specified through a fitoptions structure
or a vector value for the StartPoint property. Alternatively,
the initial state of the random number generator rand can
be set before fitting.
All other nonlinear library models automatically compute reasonable
initial values. These initial values depend on the data, and are based on
model-specific heuristics."
Nonlinear curve fitting is often highly dependent on the initial values for the coefficients, in the sense that the sum of suqared residuals criterion has multiple local minima, and many of them are not good fits to the data at all. With a custom model especially, you are better off trying to choose reasonable initial values to lessen the chances of ending up in one of those bad local minima.
Hope this helps.
- Peter Perkins
The MathWorks, Inc.
.
- Follow-Ups:
- Re: curve fitting using self-defined function
- From: Scott Seidman
- Re: curve fitting using self-defined function
- References:
- curve fitting using self-defined function
- From: Richeng Zheng
- curve fitting using self-defined function
- Prev by Date: xPC: Placing own driver libraries on server
- Next by Date: Re: curve fitting using self-defined function
- Previous by thread: curve fitting using self-defined function
- Next by thread: Re: curve fitting using self-defined function
- Index(es):
Relevant Pages
|