Polyfit with scaling
Dmitri A. Sergatskov
dasergatskov at gmail.com
Mon Feb 4 18:44:43 CST 2008
On Feb 4, 2008 6:16 PM, Ben Abbott <bpabbott at mac.com> wrote:
>
> On Feb 4, 2008, at 4:21 PM, Dmitri A. Sergatskov wrote:
>
> > -- if std(x) == 0 then it means that all x are the same number (I
> > would also argue that one
> > may want to compare to eps rather than 0). In that case we cannot
> > do any fits,
> > so probably should just exit with an error.
>
> Moving the bar to something greater than zero will be a problem if the
> x values are small to begin with. Instead, I think we should make a
> comparison relative to the mean.
>
> How about "if std(x) < mean(x)*eps" ?
>
No, the constant should be O(1). It is not unreasonable to expect
for x to be > 1/eps that is only 4.3e15 on my computer.
In fact, now I think that we do not need this check at all.
With the current wpolyfit I get:
octave:28> x=ones(1e3,1); y=2*x;
octave:29> [p, s, mu]=wpolyfit (x,y, 1)
warning: division by zero
p =
NaN NaN
s =
{
R =
NaN NaN
0 NaN
df = 998
normr = NaN
}
mu =
1 0
Which looks to me as a reasonable way to handle the situation.
>
> Ben
>
Regards,
Dmitri.
--
More information about the Octave-maintainers
mailing list