function W = biwght(res, scale, param) % function W = biwght(res, scale, param) % % computes Tukey's biweight function for robust regression % % biwght(x) = (1-x^2/param^2)^2 , |x| < param; 0, |x| >= param. % % arguments: % res: vector of residuals % scale: robust estimate of scale, such as MAD % param: parameter of the biweight function. % 8 is a reasonable number, and is the % default. % % returns: % W: the vector of biweight weights % % % P.B. Stark stark@stat.berkeley.edu % 11 July 1997. p = 8; if (nargin == 3), p = param; end res = res/scale; W = (ones(size(res)) - res.^2/p^2).^2 .* (abs(res) < p); return;