Re: fitting multiple curves [message #48686] |
Fri, 05 May 2006 12:04 |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
nolan.smith1@gmail.com writes:
> Hello,
>
> I have several curves that I am trying to fit to one that can describe
> all the curves with a satisfactory chi-square. I have used before
> mpfit,mpfitpeak and mpfitfun but only to try to fit one curve. Can it
> be used to calculate a fit for several curves?If not are there any
> routines in IDL that I can use?
Sure, there's no limitation in MPFIT which holds you to one "curve."
You may have to switch to MPFITFUN. All it wants is a set of data
points and model points.
You just need to arrange your data in some pre-organized way (say by
concatenating the curves), and have your user-function know how to
produce a model with the same organization.
Example:
X = x values
Y1 = first curve & E1 = error in first curve
Y2 = second curve & E2 = error in second curve
XX = [X, X] & YY = [Y1, Y2] & EE = [E1, E2]
P = MPFITFUN('MYFUNCT', XX, YY, EE, P0)
If you have different parameters for each curve, then you will have to
tell your user-function how to partition XX, YY, and EE into the
component curves, and also how to break up the parameters. That's up
to you!
Happy fitting,
Craig
See also,
http://cow.physics.wisc.edu/~craigm/idl/fitqa.html#multivar
--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
|
|
|