CMS 3D CMS Logo

GaussianSumUtilities.h
Go to the documentation of this file.
1 #ifndef GaussianSumUtilities_h_
2 #define GaussianSumUtilities_h_
3 
7 #include <vector>
8 
14 template <unsigned int N>
16 public:
19 // typedef ROOT::Math::SVector<double, N> Vector;
20  typedef ROOT::Math::SMatrix<double,N,N,ROOT::Math::MatRepStd<double,N> > GenMatrix;
21 
22  typedef typename SingleState::Vector Vector;
23  typedef typename SingleState::Matrix Matrix;
26 
27 private:
29 
30 public:
31  GaussianSumUtilities (const MultiState& state) :
32  theState(state),
33  theModeStatus(NotComputed) {
34  }
36  }
37 
39  inline unsigned int size () const {
40  return components().size();
41  }
43  const SingleStateContainer& components () const {
44  return theState.components();
45  }
47  const MultiState& state () const {
48  return theState;
49  }
51  inline double weight (unsigned int i) const {
52  return components()[i]->weight();
53  }
55  inline const Vector& mean (unsigned int i) const {
56  return components()[i]->mean();
57  }
59  inline const Matrix& covariance (unsigned int i) const {
60  return components()[i]->covariance();
61  }
63  bool modeIsValid () const;
66  const SingleGaussianState<N>& mode () const;
68  double pdf (const Vector&) const;
70  Vector d1Pdf (const Vector&) const;
72  Matrix d2Pdf (const Vector&) const;
74  double lnPdf (const Vector&) const;
76  Vector d1LnPdf (const Vector&) const;
78  Matrix d2LnPdf (const Vector&) const;
79 
81  double weight () const {
82  return theState.weight();
83  }
85  const Vector& mean () const {
86  return theState.mean();
87  }
89  const Matrix& covariance () const {
90  return theState.covariance();
91  }
92 
93 
94 protected:
96  Vector computeModeWithoutTransform () const;
97 
98 private:
100  Matrix tensorProduct (const Vector&) const;
102  double gauss (const double&, const double&, const double&) const;
104  double gauss (const Vector&,
105  const Vector&,
106  const Matrix&) const;
108  bool findMode (Vector& mode, double& pdfAtMode,
109  const Vector& xStart) const;
111  void computeMode () const;
113  MultiGaussianState1D constrainedState (const Vector& d,
114  const Vector& x0) const;
115 // /// replacement of CLHEP determinant (which rounds off small values)
116 // double determinant (const Matrix& matrix) const;
119  Matrix localCovariance (const Vector& x) const;
121  void setMode (const Vector& mode) const;
123  void setInvalidMode () const;
124 
126  std::vector<double> pdfComponents (const Vector&) const;
128  double pdf (const Vector&, const std::vector<double>&) const;
130  Vector d1Pdf (const Vector&, const std::vector<double>&) const;
132  Matrix d2Pdf (const Vector&, const std::vector<double>&) const;
134  double lnPdf (const Vector&, const std::vector<double>&) const;
136  Vector d1LnPdf (const Vector&, const std::vector<double>&) const;
138  Matrix d2LnPdf (const Vector&, const std::vector<double>&) const;
139 
140 
141 
142 private:
143  const MultiState& theState;
144 // int theDimension;
145 
147 // mutable Vector theMode;
149 
150 };
151 
152 #include "TrackingTools/GsfTools/interface/GaussianSumUtilities.icc"
153 
154 #endif
Matrix d2Pdf(const Vector &) const
Hessian.
double lnPdf(const Vector &) const
value of ln(pdf)
int i
Definition: DBlmapReader.cc:9
Vector computeModeWithoutTransform() const
calculation of mode
MultiState::SingleStatePtr SingleStatePtr
std::vector< double > pdfComponents(const Vector &) const
pdf components
void setMode(const Vector &mode) const
set mode "state" from solution of mode finding
const SingleStateContainer & components() const
components
const Matrix & covariance(unsigned int i) const
covariance matrix of a component
Matrix tensorProduct(const Vector &) const
Symmetric Tensor Product (not recognized by standard ROOT Math)
Matrix d2LnPdf(const Vector &) const
Hessian of ln(pdf)
const SingleStateContainer & components() const
access to components (single Gaussian states)
SingleState::Matrix Matrix
const Matrix & covariance() const
combined covariance matrix
const SingleGaussianState< N > & mode() const
double pdf(const Vector &) const
value of the p.d.f.
Mixture of multi-variate gaussian states.
GaussianSumUtilities(const MultiState &state)
std::vector< SingleStatePtr > SingleStateContainer
ROOT::Math::SVector< double, N > Vector
Vector d1Pdf(const Vector &) const
gradient
MultiGaussianState1D constrainedState(const Vector &d, const Vector &x0) const
state constrained to a line x = s*d+x0
const Vector & mean() const
combined mean
Matrix localCovariance(const Vector &x) const
void setInvalidMode() const
set mode "state" in case of failure
const Matrix & covariance() const
combined covariance
bool findMode(Vector &mode, double &pdfAtMode, const Vector &xStart) const
mode from starting value in ln(pdf); returns true on success
MultiState::SingleStateContainer SingleStateContainer
const MultiState & state() const
multi-state
double weight() const
combined weight
std::shared_ptr< SingleState > SingleStatePtr
Vector d1LnPdf(const Vector &) const
gradient of ln(pdf)
const Vector & mean(unsigned int i) const
mean value of a component
unsigned int size() const
number of components
MultiGaussianState< N > MultiState
double weight() const
combined weight
SingleGaussianState< N > SingleState
double gauss(const double &, const double &, const double &) const
value of gaussian distribution
const MultiState & theState
SingleGaussianState< N > theMode
bool modeIsValid() const
mode status
const Vector & mean() const
combined mean
SingleState::Vector Vector
void computeMode() const
calculation of mode with transformation of pdf
ROOT::Math::SMatrix< double, N, N, ROOT::Math::MatRepStd< double, N > > GenMatrix
ROOT::Math::SMatrix< double, N, N, ROOT::Math::MatRepSym< double, N >> Matrix
double weight(unsigned int i) const
weight of a component