Just insufficiently clear documentation. Apparently the fit (in $r) gives a piddle of size $x->nelem * $eps->nelem or something similar. Replacing $eps=zeroes($x) with $eps = zeroes(1) results in $r and $y agreeing to within $eps=7.4E-12.
cheers, Derek Craig DeForest wrote: > Slatec's polyfit is giving absolutely crazy answers. > > > perldl> $x = xvals(50) > perldl> $y = 15.2 + $x*3.14 + $x*$x/3.14 + ($x*$x*$x); # some random > cubic > > perldl> use PDL::Slatec; > perldl> ($ndeg,$r,$ierr,$a) = polyfit($x,$y,ones($x),pdl(4), > $eps=zeroes($x)); > perldl> p $ndeg > [4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 > 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4] > perldl> help $r > This variable is Double D [50,50] > > The output variable $r should contain either the polynomial > coefficients (makes most sense), and hence be something like [5,50], > or the actual fitted values of the polynomial (seems to agree most > with the documentation) and hence be just [50] -- [50,50] is crazy. > > Has anyone actually tried to use polfit() or polyfit() lately? > > > > _______________________________________________ > Perldl mailing list > [email protected] > http://mailman.jach.hawaii.edu/mailman/listinfo/perldl > _______________________________________________ Perldl mailing list [email protected] http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
