[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: POLY_FIT gives wrong answer !
In article <MPG.email@example.com>
firstname.lastname@example.org (David Fanning) writes:
> [Actually, Bill Thompson wrote:
> ..about getting different results with a sorted vs unsorted data
Excuse my brevity in quoting - this post is also smuggled out from
Goddard, so I'm keeping it short to avoid detection :-)
Although I think Bill's going in the right direction with regard to
the POLY_FIT question (he's sitting in the cubicle next to me, so I
should know where he's going :-), it doesn't actually explain the
original problem as it was *stated* by Henk Schets:
> The only way to do it right is by making other arrays like x2 and y2 and
> doing a poly_fit on it.
Taken at face value, this means he's doing this (referring to Bill's
xs = x(s)
ys = y(s)
param3 = poly_fit(xs,ys,2,yfit2)
Doing so, I get *identical* results compared to using x(s) and y(s)
(whereas the sorted/unsorted versions differ). So, the problem lies
My guess is that Henk is converting either x(s) or y(s) (or both) to
*double* precision, which will make the whole computation be performed
with double precision..
..or Something Else (tm). Unless we get an actual example (including
data) that will show the discrepancy, I'm leaning towards David's
general hypothesis that the problem is not in POLY_FIT, but in the
application of it..