Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:50:06

0001 #ifndef LinearFitErrorsIn2Coord_H
0002 #define LinearFitErrorsIn2Coord_H
0003 
0004 #include <vector>
0005 
0006 /** Straight line fit for data with errors on both coordinates
0007    *  source: Numerical Recipes
0008    */
0009 
0010 class LinearFitErrorsIn2Coord {
0011 public:
0012   /** Approached slope: 
0013    *  - rescale y and sigy by var(x)/var(y)
0014    *  - fit a straight line with weights derived from 
0015    *  the scaled sum sigx^2 + sigy^2
0016    */
0017   float slope(const std::vector<float>& x,
0018               const std::vector<float>& y,
0019               int ndat,
0020               const std::vector<float>& sigx,
0021               const std::vector<float>& sigy) const;
0022 
0023   /** Approached intercept computed with approached slope
0024    */
0025   float intercept(const std::vector<float>& x,
0026                   const std::vector<float>& y,
0027                   int ndat,
0028                   const std::vector<float>& sigx,
0029                   const std::vector<float>& sigy) const;
0030 
0031 private:
0032   float variance(const std::vector<float>& x, int ndat) const;
0033 };
0034 
0035 #endif