CMS 3D CMS Logo

GaussianSumUtilities1D.h
Go to the documentation of this file.
1 #ifndef GaussianSumUtilities1D_h_
2 #define GaussianSumUtilities1D_h_
3 
4 // #include "TROOT.h"
5 
8 
9 #include <vector>
10 
17 private:
19 
20 public:
22  : theState(state),
23  // theStates(state.components()),
26 
28  inline unsigned int size() const { return components().size(); }
30  inline const std::vector<SingleGaussianState1D>& components() const { return theState.components(); }
32  inline double weight(unsigned int i) const { return components()[i].weight(); }
34  inline double mean(unsigned int i) const { return components()[i].mean(); }
36  inline double standardDeviation(unsigned int i) const {
37  // return sqrt(components()[i].variance());
38  return components()[i].standardDeviation();
39  }
41  inline double variance(unsigned int i) const { return components()[i].variance(); }
43  double pdf(unsigned int i, double x) const;
45  double quantile(const double) const;
47  bool modeIsValid() const;
50  const SingleGaussianState1D& mode() const;
52  double pdf(double) const;
54  double cdf(const double&) const;
56  double d1Pdf(const double&) const;
58  double d2Pdf(const double&) const;
60  double d3Pdf(const double&) const;
62  double lnPdf(const double&) const;
64  double d1LnPdf(const double&) const;
66  double d2LnPdf(const double&) const;
67 
69  double weight() const { return theState.weight(); }
71  double mean() const { return theState.mean(); }
73  double variance() const { return theState.variance(); }
74 
75 private:
79  bool findMode(double& mode, double& pdfAtMode, const double& xStart, const double& scale) const;
81  static double gauss(double, double, double);
83  static double gaussInt(double, double, double);
85  double combinedMean() const;
87  void computeMode() const;
90  double localVariance(double x) const;
91 
92  // the state of the mode finder
93  struct FinderState {
95  FinderState(size_t n) : pdfs(n) {}
96  double x;
97  double y;
98  double yd; // d1LnPdf
99  double yd2; // d2LnPdf
100  std::vector<double> pdfs;
101  };
102 
103  // update tre state at x
104  void update(FinderState& state, double x) const;
105 
107  std::vector<double> pdfComponents(const double&) const;
109  void pdfComponents(double, std::vector<double>&) const;
111  static double pdf(double, const std::vector<double>&);
113  double d1Pdf(double, const std::vector<double>&) const;
115  double d2Pdf(double, const std::vector<double>&) const;
117  double d3Pdf(double, const std::vector<double>&) const;
119  static double lnPdf(double, const std::vector<double>&);
121  double d1LnPdf(double, const std::vector<double>&) const;
123  double d2LnPdf(double, const std::vector<double>&) const;
124 
125 private:
127  // std::vector<SingleGaussianState1D> theStates;
128 
131  // mutable double theMode;
132 };
133 #endif
GaussianSumUtilities1D::localVariance
double localVariance(double x) const
Definition: GaussianSumUtilities1D.cc:411
GaussianSumUtilities1D::gaussInt
static double gaussInt(double, double, double)
Integrated value of gaussian distribution.
Definition: GaussianSumUtilities1D.cc:395
GaussianSumUtilities1D::FinderState::y
double y
Definition: GaussianSumUtilities1D.h:97
GaussianSumUtilities1D::combinedMean
double combinedMean() const
Mean value of combined state.
Definition: GaussianSumUtilities1D.cc:399
mps_fire.i
i
Definition: mps_fire.py:428
GaussianSumUtilities1D::mode
const SingleGaussianState1D & mode() const
Definition: GaussianSumUtilities1D.cc:85
MultiGaussianState1D::weight
double weight() const
combined weight
Definition: MultiGaussianState1D.cc:5
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
GaussianSumUtilities1D::FinderState::FinderState
FinderState()
Definition: GaussianSumUtilities1D.h:94
L1EGammaCrystalsEmulatorProducer_cfi.scale
scale
Definition: L1EGammaCrystalsEmulatorProducer_cfi.py:10
GaussianSumUtilities1D::lnPdf
double lnPdf(const double &) const
ln(pdf)
Definition: GaussianSumUtilities1D.cc:282
GaussianSumUtilities1D::FinderState::yd2
double yd2
Definition: GaussianSumUtilities1D.h:99
GaussianSumUtilities1D::standardDeviation
double standardDeviation(unsigned int i) const
standard deviation of a component
Definition: GaussianSumUtilities1D.h:36
GaussianSumUtilities1D::cdf
double cdf(const double &) const
value of the c.d.f.
Definition: GaussianSumUtilities1D.cc:268
GaussianSumUtilities1D::findMode
bool findMode(double &mode, double &pdfAtMode, const double &xStart, const double &scale) const
Definition: GaussianSumUtilities1D.cc:200
GaussianSumUtilities1D::size
unsigned int size() const
number of components
Definition: GaussianSumUtilities1D.h:28
GaussianSumUtilities1D::d2LnPdf
double d2LnPdf(const double &) const
second derivative of ln(pdf)
Definition: GaussianSumUtilities1D.cc:286
DDAxes::x
MultiGaussianState1D.h
GaussianSumUtilities1D::d3Pdf
double d3Pdf(const double &) const
third derivative of the p.d.f.
Definition: GaussianSumUtilities1D.cc:280
GaussianSumUtilities1D::quantile
double quantile(const double) const
Quantile (i.e. x for a given value of the c.d.f.)
Definition: GaussianSumUtilities1D.cc:25
GaussianSumUtilities1D::weight
double weight() const
combined weight
Definition: GaussianSumUtilities1D.h:69
GaussianSumUtilities1D::d1LnPdf
double d1LnPdf(const double &) const
first derivative of ln(pdf)
Definition: GaussianSumUtilities1D.cc:284
GaussianSumUtilities1D::FinderState::yd
double yd
Definition: GaussianSumUtilities1D.h:98
GaussianSumUtilities1D::d1Pdf
double d1Pdf(const double &) const
first derivative of the p.d.f.
Definition: GaussianSumUtilities1D.cc:276
MultiGaussianState1D
Definition: MultiGaussianState1D.h:12
GaussianSumUtilities1D::variance
double variance(unsigned int i) const
variance of a component
Definition: GaussianSumUtilities1D.h:41
GaussianSumUtilities1D::ModeStatus
ModeStatus
Definition: GaussianSumUtilities1D.h:18
GaussianSumUtilities1D::mean
double mean() const
combined mean
Definition: GaussianSumUtilities1D.h:71
SingleGaussianState1D.h
GaussianSumUtilities1D::components
const std::vector< SingleGaussianState1D > & components() const
components
Definition: GaussianSumUtilities1D.h:30
GaussianSumUtilities1D::NotComputed
Definition: GaussianSumUtilities1D.h:18
GaussianSumUtilities1D::theState
const MultiGaussianState1D & theState
Definition: GaussianSumUtilities1D.h:126
GaussianSumUtilities1D::variance
double variance() const
combined covariance
Definition: GaussianSumUtilities1D.h:73
SingleGaussianState1D
Definition: SingleGaussianState1D.h:10
GaussianSumUtilities1D::computeMode
void computeMode() const
calculation of mode
Definition: GaussianSumUtilities1D.cc:91
MultiGaussianState1D::components
const SingleState1dContainer & components() const
access to components
Definition: MultiGaussianState1D.h:30
GaussianSumUtilities1D::pdf
double pdf(unsigned int i, double x) const
pdf of a single component at x
Definition: GaussianSumUtilities1D.cc:21
GaussianSumUtilities1D::Valid
Definition: GaussianSumUtilities1D.h:18
GaussianSumUtilities1D::FinderState::x
double x
Definition: GaussianSumUtilities1D.h:96
MultiGaussianState1D::mean
double mean() const
combined mean
Definition: MultiGaussianState1D.cc:15
GaussianSumUtilities1D::weight
double weight(unsigned int i) const
weight of a component
Definition: GaussianSumUtilities1D.h:32
GaussianSumUtilities1D::FinderState
Definition: GaussianSumUtilities1D.h:93
GaussianSumUtilities1D::theModeStatus
ModeStatus theModeStatus
Definition: GaussianSumUtilities1D.h:129
MultiGaussianState1D::variance
double variance() const
combined variance
Definition: MultiGaussianState1D.cc:20
GaussianSumUtilities1D::gauss
static double gauss(double, double, double)
Value of gaussian distribution.
Definition: GaussianSumUtilities1D.cc:384
RunInfoPI::state
state
Definition: RunInfoPayloadInspectoHelper.h:16
GaussianSumUtilities1D::theMode
SingleGaussianState1D theMode
Definition: GaussianSumUtilities1D.h:130
GaussianSumUtilities1D
Definition: GaussianSumUtilities1D.h:16
GaussianSumUtilities1D::FinderState::pdfs
std::vector< double > pdfs
Definition: GaussianSumUtilities1D.h:100
GaussianSumUtilities1D::d2Pdf
double d2Pdf(const double &) const
second derivative of the p.d.f.
Definition: GaussianSumUtilities1D.cc:278
GaussianSumUtilities1D::pdfComponents
std::vector< double > pdfComponents(const double &) const
pdf components
Definition: GaussianSumUtilities1D.cc:288
GaussianSumUtilities1D::FinderState::FinderState
FinderState(size_t n)
Definition: GaussianSumUtilities1D.h:95
GaussianSumUtilities1D::NotValid
Definition: GaussianSumUtilities1D.h:18
GaussianSumUtilities1D::GaussianSumUtilities1D
GaussianSumUtilities1D(const MultiGaussianState1D &state)
Definition: GaussianSumUtilities1D.h:21
GaussianSumUtilities1D::update
void update(FinderState &state, double x) const
Definition: GaussianSumUtilities1D.cc:247
GaussianSumUtilities1D::modeIsValid
bool modeIsValid() const
mode status
Definition: GaussianSumUtilities1D.cc:79
GaussianSumUtilities1D::~GaussianSumUtilities1D
~GaussianSumUtilities1D()
Definition: GaussianSumUtilities1D.h:25
GaussianSumUtilities1D::mean
double mean(unsigned int i) const
mean value of a component
Definition: GaussianSumUtilities1D.h:34