[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SVDFIT docs bug





Hi,

SVDFIT has a rather serious documentation bug.  

The hyperhelp gives the prescription weights=1/sigma^2 (which is like
the weights in CURVEFIT):

  WEIGHTS
  Set this keyword equal to a vector of weights for Yi. This vector
  should be the same length as X and Y. The error for each term is
  weighted by WEIGHTSi when computing the fit. Frequently, WEIGHTSi =
  1.0/s^2(i), where s is the measurement error or standard deviation of
  Yi (Gaussian or instrumental weighting), or WEIGHTS = 1/Y (Poisson or
  statistical weighting). If WEIGHTS is not specified, WEIGHTSi is
  assumed to be 1.0.


the code itself (svdfit.pro) has a different view, weights=1/sigma:

     sig = 1/weights   ;Apply weights

the comments in svdfit.pro have a confused mishmash of the two:

;   WEIGHTS:   A vector of weights for Y[i].  This vector must be the same
;       length as X and Y.  If this parameter is ommitted, 1's
;       (No weighting) are assumed.  The error for each term is
;       weighted by Weight[i] when computing the fit.  Gaussian or
;       instrumental uncertianties should be weighted as
;       Weight = 1/Sigma where Sigma is the measurement 
;       error or standard deviations of Y. For Poisson or statistical 
;       weighting use Weight=1/Y, since Sigma=sqrt(Y).

this is with IDL 5.1 or 5.2.  Needless to say this plays havoc with
the values of chi-squared and parameter errors and also affects the
choice of fit.

I filed this with RSI and they agree it's a problem.  

According to DejaNews, SVDFIT has been around at least since 1995.
This raises several possibilities:

1) the documentation bug was introduced fairly recently.  This seems
unlikely to me, documentation tends to be static unless a problem is
found with it.

2) The people who used SVDFIT all independently figured out the
problem with the documentation and used correct weights, though they
neglected to tell anyone else.  Well, possibly.

3) A lot of erroneous chi-squared values and incorrect fits have been
made with SVDFIT in the last few years.  This seems fairly alarming.
Wonder if I've read any papers that used this routine.

4) Even more alarming: nobody looks at the value of chi-squared.

cheers,
Mark Fardal
UMass