Go to the documentation of this file.00001 #ifndef GSUtilities_h
00002 #define GSUtilities_h
00003
00008 class GSUtilities {
00009 public:
00011 GSUtilities (const unsigned nComp, const float* weights,
00012 const float* parameters, const float* errors) :
00013 theNComp(nComp),
00014 theWeights(0),
00015 theParameters(0),
00016 theErrors(0)
00017 {
00018 if ( theNComp ) {
00019 theWeights = new float[theNComp];
00020 theParameters = new float[theNComp];
00021 theErrors = new float[theNComp];
00022 }
00023 const float* wPtr1(weights);
00024 const float* pPtr1(parameters);
00025 const float* ePtr1(errors);
00026 float* wPtr2(theWeights);
00027 float* pPtr2(theParameters);
00028 float* ePtr2(theErrors);
00029 for ( unsigned i=0; i<theNComp; i++ ) {
00030 *(wPtr2++) = weights ? *(wPtr1++) : 1.;
00031 *(pPtr2++) = *(pPtr1++);
00032 *(ePtr2++) = *(ePtr1++);
00033 }
00034 }
00035 ~GSUtilities ()
00036 {
00037 delete [] theWeights;
00038 delete [] theParameters;
00039 delete [] theErrors;
00040 }
00044 float quantile (const float) const;
00046 float mode () const;
00048 double pdf (const double&) const;
00050 double cdf (const double&) const;
00052 double dpdf1 (const double&) const;
00054 double dpdf2 (const double&) const;
00055
00057 double combinedMean() const;
00058
00059 double errorCombinedMean() const;
00060
00061 float errorHighestWeight() const;
00062
00063 float maxWeight() const;
00064
00065 float errorMode();
00066 float getMax(float);
00067 float getMin(float);
00068
00069 private:
00071 double gauss (const double&, const double&, const double&) const;
00073 double gaussInt (const double&, const double&, const double&) const;
00077 double findMode (const double) const;
00078
00079 private:
00080 unsigned theNComp;
00081 float* theWeights;
00082 float* theParameters;
00083 float* theErrors;
00084 };
00085 #endif