[Pkg-octave-devel] Bug#348480: polyfit breaks down over "large" x
values
Drew Parsons
dparsons at debian.org
Tue Jan 17 09:01:20 UTC 2006
Package: octave2.1
Version: 1:2.1.72-8
Severity: normal
There are reports [1-4] over the years on the octave mailing lists about
octave's polyfit function. When the x-values are "large" (e.g. 1000s
instead of 1s) then the fit at higher orders (e.g. order 10) is completely
screwed up.
Some of the reports [1] suggest prescaling (e.g. divide x-values by 1000)
before fitting. This does work.
Others [2,3] provide a script to fix the problem. Unfortunately they do NOT
work successfully for me (same bad fitting is obtained).
Another [4] claims that the problem is fixed in wpolyfit from octave-forge.
Unfortunately this is in fact NOT the case. wpolyfit gives the same
incorrect result as polyfit.
So I'm filing this bug to document the problem, rather than letting
half-rumoured fixes float littered somewhere on mailing lists. I guess
you'll want to notify upstream if you agree the problem is really.
The misbehaviour can be seen from my attached sample data, scripting as
follows:
inputData = load( "test.dat" );
x = inputData( : , 1 );
y = inputData( : , 2 );
P = polyfit(x,y,10);
polyval(P,x);
The coefficients in P are strangely all close to zero (< 1E-25).
Rescaling x provides the desired non-zero coefficients and an "exact" fit of
the original data:
inputData = load( "test.dat" );
x = inputData( : , 1 );
y = inputData( : , 2 );
xscaled = x/1000;
P = polyfit(xscaled,y,10);
for k=1:columns(P)
power = columns(P)-k;
P(k) = P(k) / (1000^power );
endfor
polyval(P,x);
It'd be nice if this were to be fixed in polyfit itself, or at least if
wpolyfit would fix it as it's claimed to in [4].
[1] http://www.octave.org/octave-lists/archive/help-octave.1999/msg01008.html
[2] http://www.octave.org/octave-lists/archive/help-octave.1999/msg01027.html
[3] http://www.octave.org/octave-lists/archive/help-octave.1999/msg01052.html
[4] http://www.octave.org/octave-lists/archive/bug-octave.2004/msg00807.html
-- System Information:
Debian Release: testing/unstable
APT prefers unstable
APT policy: (990, 'unstable')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/dash
Kernel: Linux 2.6.14
Locale: LANG=en_AU.UTF-8, LC_CTYPE=en_AU.UTF-8 (charmap=UTF-8)
Versions of packages octave2.1 depends on:
ii atlas3-base [liblapack.s 3.6.0-20 Automatically Tuned Linear Algebra
ii fftw3 3.0.1-14 library for computing Fast Fourier
ii lapack3 [liblapack.so.3] 3.0.20000531a-6 library of linear algebra routines
ii libc6 2.3.5-11 GNU C Library: Shared libraries an
ii libgcc1 1:4.0.2-6 GCC support library
ii libgfortran0 4.0.2-6 Runtime library for GNU Fortran ap
ii libhdf5-serial-1.6.4-0c2 1.6.4-4 Hierarchical Data Format 5 (HDF5)
ii libncurses5 5.5-1 Shared libraries for terminal hand
ii libreadline5 5.1-5 GNU readline and history libraries
ii libstdc++6 4.0.2-6 The GNU Standard C++ Library v3
ii refblas3 [libblas.so.3] 1.2-8 Basic Linear Algebra Subroutines 3
ii texinfo 4.8-4 Documentation system for on-line i
ii zlib1g 1:1.2.3-9 compression library - runtime
octave2.1 recommends no packages.
-- no debconf information
More information about the Pkg-octave-devel
mailing list