[frames] | no frames]

Module solve_sum_abs

source code

Solves various equations involving minimizing the sum of absolute values of things.

Functions

 solve1(y0, y1) We minimize the equation sum_over_i(abs(y0_i*(1-x) + y1_i*x)) to find the best x. source code
`tuple(float,float)`
 solve_fit(x, y, epsx=1e-07, epsm=1e-07) Solves for the line yhat = m*x + b that minimizes sum(abs(y - yhat)). source code
`tuple(float,float)`
 solve_fit_wt(x, y, wt, epsx=1e-07, epsm=1e-07) Solves for the line yhat = m*x + b that minimizes sum(abs(y - yhat)). source code

 test1() source code

 test2() source code
 Variables __package__ = `'gmisclib'`

Imports: math, numpy, Numeric_gpk, root, WP

 Function Details

solve1(y0, y1)

source code

We minimize the equation sum_over_i(abs(y0_i*(1-x) + y1_i*x)) to find the best x. Returns x. I don't know if this is strictly correct.

solve_fit(x, y, 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.

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.

 Generated by Epydoc 3.0.1 on Thu Sep 22 04:25:02 2011 http://epydoc.sourceforge.net