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

Home » Public Forums » archive » Fitting curve to data
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: Fitting curve to data [message #93632 is a reply to message #93631] Wed, 14 September 2016 08:06 Go to previous messageGo to previous message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
On Wednesday, September 14, 2016 at 10:23:09 AM UTC-4, liam....@gmx.co.uk wrote:
> Hi all,
>
> I am trying to it a curve to some data points, and have managed to get confused with all the interpolate and spline IDL routines (and more importantly, can't seem to get any of them to work).
>
> As an example, I have a range of depths (in cm) and a value of something at each depth, e.g.
>
> depth = [0.01, 0.1, 0.4, 0.9, 3.5, 14.5, 57.9, 231.7, 926.8]
> value = [2.1, 2.1, 1.9, 1.8, 1.3, 1.0, 0.8, 0.5, 0.4]
>
> What I want to do is fit a curve to the data as best I can (the curve doesn't have to go through each point exactly), on a finer set of depths, e.g.
>
> interp_depth = findgen(1001)
>
> I've tried things like:
>
> interp_val = spline(value,depth,interp_depth)
> interp_val = interpol(value,depth,interp_depth,/spline)
>
> Can anyone offer any help? Is there some sort of cubic least-squares routine or something I should use? I can get linear interpolation to work, but was wanting something more 'realistic'.
>

I think you will get much better results by recognizing that your X axis is logarithmic and doing something like

interp_depth = findgen(1001)+0.1
y = interpol( value,alog10(depth), alog10(interp_depth),/spline)

Of course you need to be very careful when extrapolating outside of the supplied X range. --Wayne
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Problem with classification
Next Topic: IDL structure problem

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

Current Time: Wed Oct 08 11:44:53 PDT 2025

Total time taken to generate the page: 0.00438 seconds