Linear least-squares fit of data to a function with outlier rejection and iteration. The number of parameters is assumed known at compile time.
Function objects have to conform to a simple interface: (it is a template object in this example, but does not need to be).
template<typename T, typename Tpar, int N> class Poly2D { public: enum { NPar = N }; typedef Tpar param_vector_type; typedef T value_type;
// optional static void prettyPrint(ostream& os, const TPar& p);
// evaluate at location {x
,y} for parameter vector p
T operator()( const T x, const T y, const TPar& p ) const;
// return the n-th basis function evaluated at values in array x
MArray<T,1> get_nth_basis( const int n, const MArray<T,1>& x, const MArray<T,1>& y ) };
typedef Function::TPar BivariateLinearLsqFit< T, Function >::param_vec_type |
BivariateLinearLsqFit< T, Function >::BivariateLinearLsqFit | ( | int | niter = 1 , |
|
float | kappa = 4.0 , |
|||
bool | quiet = true | |||
) | [inline] |
virtual BivariateLinearLsqFit< T, Function >::~BivariateLinearLsqFit | ( | ) | [inline, virtual] |
void BivariateLinearLsqFit< T, Function >::set_rejection | ( | const int | niter, | |
const float | kappa | |||
) | [inline] |
BivariateLinearLsqFit< T, Function >::param_vec_type BivariateLinearLsqFit< T, Function >::fit | ( | const MArray< T, 1 > & | x1, | |
const MArray< T, 1 > & | x2, | |||
const MArray< T, 1 > & | y, | |||
const MArray< T, 1 > & | y_errors, | |||
param_vec_type * | errors = NULL | |||
) | const [inline] |
References b, BivariateLinearLsqFit< T, Function >::niter_, BivariateLinearLsqFit< T, Function >::quiet_, and BivariateLinearLsqFit< T, Function >::reject().
Referenced by Distortion::fit_fiberpos(), Distortion::fit_fy(), FiberModel::fit_h2(), FiberModel::fit_h3(), PsfModel::fit_params(), FiberModel::fit_sigma(), Distortion::fit_wavelength(), Distortion::fit_x(), and Distortion::fit_y().
void BivariateLinearLsqFit< T, Function >::reject | ( | const MArray< T, 1 > & | x1, | |
const MArray< T, 1 > & | x2, | |||
const MArray< T, 1 > & | y, | |||
const MArray< T, 1 > & | y_errors, | |||
const param_vec_type & | p, | |||
MArray< T, 1 > & | new_x1, | |||
MArray< T, 1 > & | new_x2, | |||
MArray< T, 1 > & | new_y, | |||
MArray< T, 1 > & | new_y_errors | |||
) | const [inline, protected] |
References BivariateLinearLsqFit< T, Function >::kappa_, and BivariateLinearLsqFit< T, Function >::quiet_.
Referenced by BivariateLinearLsqFit< T, Function >::fit().
int BivariateLinearLsqFit< T, Function >::niter_ [protected] |
float BivariateLinearLsqFit< T, Function >::kappa_ [protected] |
bool BivariateLinearLsqFit< T, Function >::quiet_ [protected] |