From: Phil Rhoades Date: 2007-12-17T12:49:59+09:00 Subject: Re: Curve fitting to data Alex, On Mon, 2007-12-17 at 11:40 +0900, Alex Fenton wrote: > Phil Rhoades wrote: > > > On Sun, 2007-12-16 at 23:55 +0000, Thomas Adam wrote: > >> On 16/12/2007, Phil Rhoades wrote: > >>> People, > >>> > >>> Does anyone know of a Ruby app that will fit a curve to data eg fitting > >>> a curve to: > >>> > >>> -10 0 > >>> -9 19 > >> This looks like a prime candidate for GNUPlot -- which ruby has bindings for. > > > > > > I think GNUPlot requires the knowledge of the type of fn you are trying > > to fit - I want the software to TELL me what sort of fn it is eg for the > > data: > > You can access the "R" statistical package via Ruby, which seems to have > curve fitting capabilities. But this would involve learning R, which > I've found to have a steeper curve than I cared to climb. > > More generally, I think for most scientific purposes, it's a good idea > to have an idea of the type of curve (power, quadratic, cubic etc) that > might underlie the observed data. Most applications enforce this. If you > know the general form of the equation that's being fitted ( eg ax^2 + bx > + c for a quadratic), it would be possible to get estimates for a, b and > c by using eg ordinary least squares to find a solution that minimises > the difference between observed and predicted values. How you get to > that with acceptable time is an algorithmic question... > > But nothing I know of exactly in Ruby. You might take a look at the > source code for the website you linked to: > http://pythonequations.cvs.sourceforge.net/pythonequations/PythonEquations/DESolver/DESolver.py?revision=1.2&view=markup > > Maybe a fun one for a Ruby Quiz sometime? I installed grace and that does pretty much what you said, which is not quite what I want but interesting . . Yeh, I did have a look at the PythonEquations stuff but it looks too tough for me to translate/make use of - I would certainly be happy if someone wanted to make it a Ruby Quiz! Regards, Phil. -- Philip Rhoades Pricom Pty Limited (ACN 003 252 275 ABN 91 003 252 275) GPO Box 3411 Sydney NSW 2001 Australia Fax: +61:(0)2-8221-9599 E-mail: phil@pricom.com.au