File indexing completed on 2024-04-06 12:31:29
0001 #ifndef GSUtilities_h
0002 #define GSUtilities_h
0003
0004
0005
0006
0007
0008 class GSUtilities {
0009 public:
0010
0011 GSUtilities(const unsigned nComp, const float* weights, const float* parameters, const float* errors)
0012 : theNComp(nComp), theWeights(nullptr), theParameters(nullptr), theErrors(nullptr) {
0013 if (theNComp) {
0014 theWeights = new float[theNComp];
0015 theParameters = new float[theNComp];
0016 theErrors = new float[theNComp];
0017 }
0018 const float* wPtr1(weights);
0019 const float* pPtr1(parameters);
0020 const float* ePtr1(errors);
0021 float* wPtr2(theWeights);
0022 float* pPtr2(theParameters);
0023 float* ePtr2(theErrors);
0024 for (unsigned i = 0; i < theNComp; i++) {
0025 *(wPtr2++) = weights ? *(wPtr1++) : 1.;
0026 *(pPtr2++) = *(pPtr1++);
0027 *(ePtr2++) = *(ePtr1++);
0028 }
0029 }
0030 ~GSUtilities() {
0031 delete[] theWeights;
0032 delete[] theParameters;
0033 delete[] theErrors;
0034 }
0035
0036
0037
0038 float quantile(const float) const;
0039
0040 float mode() const;
0041
0042 double pdf(const double&) const;
0043
0044 double cdf(const double&) const;
0045
0046 double dpdf1(const double&) const;
0047
0048 double dpdf2(const double&) const;
0049
0050
0051 double combinedMean() const;
0052
0053 double errorCombinedMean() const;
0054
0055 float errorHighestWeight() const;
0056
0057 float maxWeight() const;
0058
0059 float errorMode();
0060 float getMax(float);
0061 float getMin(float);
0062
0063 private:
0064
0065 double gauss(const double&, const double&, const double&) const;
0066
0067 double gaussInt(const double&, const double&, const double&) const;
0068
0069
0070
0071 double findMode(const double) const;
0072
0073 private:
0074 unsigned theNComp;
0075 float* theWeights;
0076 float* theParameters;
0077 float* theErrors;
0078 };
0079 #endif