-------- Original-Nachricht --------
Datum: Mon, 17 Dec 2007 15:31:03 +0900
Von: Phil Rhoades <phil@pricom.com.au>
An: ruby-talk@ruby-lang.org
Betreff: Re: Curve fitting to data
JM,
>
> > 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:
> >
> > -10 0
> > -9 19
> > -8 36
> > -7 51
> > -6 64
> > -5 75
> > -4 84
> > -3 91
> > -2 96
> > -1 99
> > 0 100
> > 1 99
> > 2 96
> > 3 91
> > 4 84
> > 5 75
> > 6 64
> > 7 51
> > 8 36
> > 9 19
> > 10 0
> >
> > http://www.zunzun.comtells me that the formula for this data is:
> >
> > y = a( atan(x) ) + b( x2 ) + c( sinh(x) ) + offset
> >
> > I would like to be able to do this myself with my own (preferably
Ruby)
> > code.
> >
> > Thanks,
> >
> > Phil.
>
> Isn't the result zunzun spit out "wrong"? The data is most simply
> described as an inverted parabola:
>
> y = a x^2 + c
>
> This points exactly to the problem others have mentioned. Given a
> large enough space of functions, you can fit practically anything, but
> what does it mean? Generally speaking, no one has any business
> fitting 21 data points with 4 parameters.
Dear Phil,
it is of course preferable to have some idea about the underlying
relationship between data graphed, such as
y = a*x^2 + b*x + c,
and then fit that model (this can be done by solving a linear
equation,
Matrix([x_0^2,x_0,1],...,[x_n^2,x_n,1])*([a,b,c]^transpose)=[y_0,..,y_n]^transpose
(numbering data points as ((x_0,y_0),....(x_n,y_)) and
[..] indicating rows in the matrix or row vectors)),
as this is a linear equation in the parameters a,b,c .
You can do that with any software that solves linear or matrix
equations, i.e., rsruby or rb-gsl .
It is of course also true that one can basically draw arbitrary
curves to connect data points, if you don't know that a model
like the above is "true".
Now, one additional line of thought is pursued in the discipline
of "approximation theory" (see eg., Wikipedia, or for a deeper
insight, Approximation Theory and Methods - M. J. D. Powell - Google Books).
Here, one starts with a points, as yours, and asks,
Given a distance measure between the data and the curve ("norm") and a set of admissible model curves (e.g., all continuous curves on an interval),
which curves will minimize that norm ?
There are indeed some results available, such as Chebyshev or Remez(Remes) approximation procedures.
This kind of procedure can be recommended when the functional relationship of your data is rather complicated/not enormously interesting/you distrust
simple models, you know something about the general wiggliness of the underlying curve (see the Jackson theorems in Powell's book), and you need to have information about what you would have measured at some point you didn't actually measure and the result should be not too far off ...
Best regards,
Axel
···
On Mon, 2007-12-17 at 15:10 +0900, jwmerrill@gmail.com wrote:
> On Dec 16, 7:07 pm, Phil Rhoades <p...@pricom.com.au> wrote:
--
Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten
Browser-Versionen downloaden: GMX Browser - verwenden Sie immer einen aktuellen Browser. Kostenloser Download.