Re: Curve fitting to data
- From: "M. Edward (Ed) Borasky" <znmeb@xxxxxxxxxxx>
- Date: Sun, 16 Dec 2007 22:30:34 -0500
Alex Fenton wrote:
Phil Rhoades wrote:
On Sun, 2007-12-16 at 23:55 +0000, Thomas Adam wrote:
On 16/12/2007, Phil Rhoades <phil@xxxxxxxxxxxxx> wrote:
People,This looks like a prime candidate for GNUPlot -- which ruby has
Does anyone know of a Ruby app that will fit a curve to data eg fitting
a curve to:
-10 0
-9 19
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?
alex
Well ... let's see:
1. There's no such thing as a "universal curve fitting algorithm", in
the sense that you give it a set of points and it spits out a formula.
The main reason is that given any *finite* set of points, there are an
*infinite* number of possible curves that can be drawn through them
exactly. Some of these are fairly well behaved outside the range of the
input points, and some of them exhibit bizarre behavior.
2. There's no such thing as a curve-fitting problem in a total vacuum,
without any context whatsoever. In other words, a request to fit a curve
to a set of points is meaningless without knowledge of how you will use
that fit.
3. Many of the "naive" techniques, like polynomial regression, behave
very badly. By "behave very badly", I mean "much worse than plotting the
points in Excel and making a wild guess."
Given all that, I don't see much hope of finding or writing a Ruby
program to do this. Conversely, if the original poster has a model that
the points should have come from, based on some theory, writing Ruby
code (or R or Python code) to fit the data to the model is easy. Just
about every reasonable fitting algorithm is already coded in R, so if
you just want an answer without all that pesky learning stuff, it's
probably easier to do it in R.
.
- References:
- Curve fitting to data
- From: Phil Rhoades
- Re: Curve fitting to data
- From: Thomas Adam
- Re: Curve fitting to data
- From: Phil Rhoades
- Re: Curve fitting to data
- From: Alex Fenton
- Curve fitting to data
- Prev by Date: Re: Ruby-GNOME2
- Next by Date: Re: Smallest device to code ruby on?
- Previous by thread: Re: Curve fitting to data
- Next by thread: Re: Curve fitting to data
- Index(es):
Relevant Pages
|