comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: CURVEFIT for multiple datasets
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: CURVEFIT for multiple datasets [message #58476 is a reply to message #58475] Thu, 31 January 2008 06:15 Go to previous message
Spon is currently offline  Spon
Messages: 178
Registered: September 2007
Senior Member
On Jan 31, 12:55 pm, chloesharro...@gmail.com wrote:
> Dear all
>
> I'm trying to fit an exponential curve to multiple data sets which
> have been overplotted on a graph. To get a feel for CURVEFIT (as I'm
> a novice at IDL and CURVEFIT), I wrote the following 2 programs (based
> on the one given in IDL help), which produce a nice exponential curve
> when there's only ONE dataset:
>
> =====
> PRO gfunct, x, t_a, f_t, PDER
>
> t_bx = EXP(t_a[1]*x)
> f_t = t_a[0] * (t_bx) + t_a[2]
>
> ;If the procedure is called with four parameters, calculate the
> partial derivatives
> IF N_PARAMS() GE 4 THEN $
> pder = [[t_bx], [t_a[0]*x*t_bx], [replicate(1.0, N_ELEMENTS(x))]]
>
> END
> =====
> and
> =====
> PRO CURVE_FITTING
> x=FLOAT(indgen(10))
> y=[12.0, 11.0, 10.2, 9.4, 8.7, 8.1, 7.5, 6.9, 6.5, 6.1]
> weights=1.0/y ;Define a vector of weights
> A=[10.0, -0.1, 2.0] ;Provide an initial guess of the function's
> parameters
>
> yfit=CURVEFIT(x,y,weights, A, FUNCTION_NAME='gfunct') ;Compute the
> parameters
> print, 'Function parameters: ', A
>
> loadcolors
> pson, filename='Curve_fitting.ps'
> plot, x, y, yrange=[5,13], ystyle=1, xrange=[0, 11], xstyle=1, psym=1,
> color=0
> oplot, x, yfit, linestyle=1, color=5
> psoff
> END
> =====
>
> How can I extend this for the case when I have say 2data sets, ie:
> x=[[indgen(10)], [indgen(10)]]
> y=[[12.0, 11.0, 10.2, 9.4, 8.7, 8.1, 7.5, 6.9, 6.5, 6.1], [11.5, 10.8,
> 10.3, 9.5, 8.6, 7.8, 7.5, 6.4, 6.4, 5.9]
> and I want to plot an exponential curve through all of this data?
> Eventually, I would like my program to be able to plot an exponential
> curve through 2000+ data sets all of which have been plotted on the
> same graph and seem to show an exponential trend.
>
> Thanks very much
> ChloƩ

This doesn't really answer your question in any way, but if you're
going to do a lot of curvefitting, I'd suggest having a look at Craig
Markwardt's site:
http://cow.physics.wisc.edu/~craigm/idl/idl.html

His fitting programmes are faster and more robust than CURVEFIT in my
(admittedly limited) experience, and it's certainly true that they
don't crash and burn as easily as CURVEFIT does.

To try and answer your question, there's no way I can see of fitting
more than one datapoint at a time using the method you describe. The
brute force way involves wrapping the lot in (slow) FOR loops. The
elegant and efficient way, if there is one, eludes me.

There may well be a way to use Craig's mpfit to help you here, but I
don't know - perhaps someone else does?

> Eventually, I would like my program to be able to plot an exponential
> curve through 2000+ data sets all of which have been plotted on the
> same graph and seem to show an exponential trend.
It may also be worthwhile asking yourself if you really need a fitted
curve to every single data set; or one curve that best fits the whole
data (in which case I'd suggest looking at MOMENT or TOTAL, for
example, before you do any curve fitting at all.) Maybe even something
in between?

Hope this helps,
Chris
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Is there a good procedure for Minimum Variance Analysis?
Next Topic: Re: Creating a dicom-file in HSV colors

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sun Oct 12 17:07:10 PDT 2025

Total time taken to generate the page: 2.00209 seconds