solve_fit_wt(x,
y,
wt,
epsx=1e-07,
epsm=1e-07)
| source code
|
Solves for the line yhat = m*x + b that minimizes sum(abs(y - yhat)).
In other words, it's a fit to a straight line, but a highly robust fit
that will not be disturbed by outliers. The algorithm is from Numerical
Recipes, Volume 2.
- Parameters:
epsx (float ) - a tolerance used in the iterative solution. Eps is roughly the
required accuracy of the x-intercept of the solution, expressed
as a fraction of the x-range of the data.
epsm (float ) - a tolerance used in the iterative solution. Roughly, it is the
accuracy of m in the solution. Note the tangent()
call!
- Returns:
tuple(float,float)
- (mhat, bhat), where mhat*x+bhat is the best fit to the data.
|