#include <LinearFitErrorsIn2Coord.h>
Public Member Functions | |
float | intercept (const std::vector< float > &x, const std::vector< float > &y, int ndat, const std::vector< float > &sigx, const std::vector< float > &sigy) const |
float | slope (const std::vector< float > &x, const std::vector< float > &y, int ndat, const std::vector< float > &sigx, const std::vector< float > &sigy) const |
Private Member Functions | |
float | variance (const std::vector< float > &x, int ndat) const |
Straight line fit for data with errors on both coordinates source: Numerical Recipes
Definition at line 10 of file LinearFitErrorsIn2Coord.h.
float LinearFitErrorsIn2Coord::intercept | ( | const std::vector< float > & | x, |
const std::vector< float > & | y, | ||
int | ndat, | ||
const std::vector< float > & | sigx, | ||
const std::vector< float > & | sigy | ||
) | const |
Approached intercept computed with approached slope
Definition at line 33 of file LinearFitErrorsIn2Coord.cc.
float LinearFitErrorsIn2Coord::slope | ( | const std::vector< float > & | x, |
const std::vector< float > & | y, | ||
int | ndat, | ||
const std::vector< float > & | sigx, | ||
const std::vector< float > & | sigy | ||
) | const |
Approached slope:
Definition at line 5 of file LinearFitErrorsIn2Coord.cc.
References LinearFit::fit(), i, pileupReCalc_HLTpaths::scale, mathSSE::sqrt(), variance(), and detailsBasic3DVector::y.
Referenced by intercept().
{ // scale y and sigy, compute scaled errors float scale = sqrt(variance(x, ndat) / variance(y, ndat)); std::vector<float> yScaled = y; std::vector<float> sigyScaled = sigy; std::vector<float> sig(ndat); for (int i = 0; i != ndat; i++) { yScaled[i] *= scale; sigyScaled[i] *= scale; sig[i] = sqrt(sigx[i]*sigx[i] + sigyScaled[i]*sigyScaled[i]); } // usual linear fit LinearFit lf; float fs, fi, covss, covii, covsi; lf.fit(x, yScaled, ndat, sig, fs, fi, covss, covii, covsi); // unscale result fs /= scale; return fs; }
float LinearFitErrorsIn2Coord::variance | ( | const std::vector< float > & | x, |
int | ndat | ||
) | const [private] |