CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes
GaussianSumUtilities1D Class Reference

#include <GaussianSumUtilities1D.h>

Classes

struct  FinderState
 

Public Member Functions

double cdf (const double &) const
 value of the c.d.f. More...
 
const std::vector
< SingleGaussianState1D > & 
components () const
 components More...
 
double d1LnPdf (const double &) const
 first derivative of ln(pdf) More...
 
double d1Pdf (const double &) const
 first derivative of the p.d.f. More...
 
double d2LnPdf (const double &) const
 second derivative of ln(pdf) More...
 
double d2Pdf (const double &) const
 second derivative of the p.d.f. More...
 
double d3Pdf (const double &) const
 third derivative of the p.d.f. More...
 
 GaussianSumUtilities1D (const MultiGaussianState1D &state)
 
double lnPdf (const double &) const
 ln(pdf) More...
 
double mean (unsigned int i) const
 mean value of a component More...
 
double mean () const
 combined mean More...
 
const SingleGaussianState1Dmode () const
 
bool modeIsValid () const
 mode status More...
 
double pdf (unsigned int i, double x) const
 pdf of a single component at x More...
 
double pdf (double) const
 value of the p.d.f. More...
 
double quantile (const double) const
 Quantile (i.e. x for a given value of the c.d.f.) More...
 
unsigned int size () const
 number of components More...
 
double standardDeviation (unsigned int i) const
 standard deviation of a component More...
 
double variance (unsigned int i) const
 variance of a component More...
 
double variance () const
 combined covariance More...
 
double weight (unsigned int i) const
 weight of a component More...
 
double weight () const
 combined weight More...
 
 ~GaussianSumUtilities1D ()
 

Private Types

enum  ModeStatus { Valid, NotValid, NotComputed }
 

Private Member Functions

double combinedMean () const
 Mean value of combined state. More...
 
void computeMode () const
 calculation of mode More...
 
double d1LnPdf (double, const std::vector< double > &) const
 first derivative of ln(pdf) using the pdf components at the evaluation point More...
 
double d1Pdf (double, const std::vector< double > &) const
 first derivative of the p.d.f. using the pdf components at the evaluation point More...
 
double d2LnPdf (double, const std::vector< double > &) const
 second derivative of ln(pdf) using the pdf components at the evaluation point More...
 
double d2Pdf (double, const std::vector< double > &) const
 second derivative of the p.d.f. using the pdf components at the evaluation point More...
 
double d3Pdf (double, const std::vector< double > &) const
 third derivative of the p.d.f. using the pdf components at the evaluation point More...
 
bool findMode (double &mode, double &pdfAtMode, const double &xStart, const double &scale) const
 
double localVariance (double x) const
 
std::vector< double > pdfComponents (const double &) const
 pdf components More...
 
void pdfComponents (double, std::vector< double > &) const
 pdf components More...
 
void update (FinderState &state, double x) const
 

Static Private Member Functions

static double gauss (double, double, double)
 Value of gaussian distribution. More...
 
static double gaussInt (double, double, double)
 Integrated value of gaussian distribution. More...
 
static double lnPdf (double, const std::vector< double > &)
 ln(pdf) using the pdf components at the evaluation point More...
 
static double pdf (double, const std::vector< double > &)
 value of the p.d.f. using the pdf components at the evaluation point More...
 

Private Attributes

SingleGaussianState1D theMode
 
ModeStatus theModeStatus
 
const MultiGaussianState1DtheState
 

Detailed Description

Utility class for the analysis of one-dimensional Gaussian mixtures. The input state is assumed to exist for the lifetime of this object.

Definition at line 16 of file GaussianSumUtilities1D.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

GaussianSumUtilities1D::GaussianSumUtilities1D ( const MultiGaussianState1D state)
inline

Definition at line 21 of file GaussianSumUtilities1D.h.

21  :
22  theState(state),
23 // theStates(state.components()),
const MultiGaussianState1D & theState
GaussianSumUtilities1D::~GaussianSumUtilities1D ( )
inline

Definition at line 25 of file GaussianSumUtilities1D.h.

25 {}

Member Function Documentation

double GaussianSumUtilities1D::cdf ( const double &  x) const

value of the c.d.f.

Definition at line 280 of file GaussianSumUtilities1D.cc.

References gaussInt(), i, mean(), query::result, asciidump::s, size(), standardDeviation(), and weight().

281 {
282  double result(0.);
283  size_t s=size();
284  for ( unsigned int i=0; i<s; i++ )
286  return result;
287 }
int i
Definition: DBlmapReader.cc:9
double weight() const
combined weight
unsigned int size() const
number of components
static double gaussInt(double, double, double)
Integrated value of gaussian distribution.
tuple result
Definition: query.py:137
double mean() const
combined mean
double standardDeviation(unsigned int i) const
standard deviation of a component
string s
Definition: asciidump.py:422
double GaussianSumUtilities1D::combinedMean ( ) const
private

Mean value of combined state.

Definition at line 455 of file GaussianSumUtilities1D.cc.

References components(), i, asciidump::s, size(), and weight().

456 {
457  double s0(0.);
458  double s1(0.);
459  int s = size();
460  SingleGaussianState1D const * __restrict__ sgv = &components().front();
461  for (int i=0; i<s; i++ )
462  s0 += sgv[i].weight();
463  for (int i=0; i<s; i++ )
464  s1 += sgv[i].weight()*sgv[i].mean();
465  return s1/s0;
466 }
int i
Definition: DBlmapReader.cc:9
double weight() const
combined weight
unsigned int size() const
number of components
string s
Definition: asciidump.py:422
const std::vector< SingleGaussianState1D > & components() const
components
const std::vector<SingleGaussianState1D>& GaussianSumUtilities1D::components ( ) const
inline

components

Definition at line 30 of file GaussianSumUtilities1D.h.

References MultiGaussianState1D::components(), and theState.

Referenced by combinedMean(), computeMode(), mean(), pdfComponents(), size(), standardDeviation(), variance(), and weight().

30  {
31  return theState.components();
32  }
const MultiGaussianState1D & theState
const SingleState1dContainer & components() const
access to components
void GaussianSumUtilities1D::computeMode ( ) const
private

calculation of mode

Definition at line 102 of file GaussianSumUtilities1D.cc.

References components(), ExpressReco_HICollisions_FallBack::e, findMode(), first, i, localVariance(), M_PI, mean(), mode(), NotValid, pdf(), asciidump::s, edm::second(), size(), mathSSE::sqrt(), standardDeviation(), theMode, theModeStatus, Valid, TrackValidation_HighPurity_cff::valid, variance(), weight(), ExpressReco_HICollisions_FallBack::x, and ExpressReco_HICollisions_FallBack::y.

Referenced by mode(), and modeIsValid().

103 {
104 // TimerStack tstack;
105 // tstack.benchmark("GSU1D::benchmark",100000);
106 // FastTimerStackPush(tstack,"GaussianSumUtilities1D::computeMode");
108  //
109  // Use means of individual components as start values.
110  // Sort by value of pdf.
111  //
112  typedef std::multimap<double, int, std::greater<double> > StartMap;
113  StartMap xStart;
114  for ( unsigned int i=0; i<size(); i++ ) {
115  xStart.insert(std::make_pair(pdf(mean(i)),i));
116  }
117  //
118  // Now try with each start value
119  //
120  int iRes(-1); // index of start component for current estimate
121  double xRes(mean((*xStart.begin()).second)); // current estimate of mode
122  double yRes(-1.); // pdf at current estimate of mode
123 // std::pair<double,double> result(-1.,mean((*xStart.begin()).second));
124  for ( StartMap::const_iterator i=xStart.begin(); i!=xStart.end(); i++ ) {
125  //
126  // Convergence radius for a single Gaussian = 1 sigma: don't try
127  // start values within 1 sigma of the current solution
128  //
129  if ( theModeStatus==Valid &&
130  fabs(mean((*i).second)-mean(iRes))/standardDeviation(iRes)<1. ) continue;
131  //
132  // If a solution exists: drop as soon as the pdf at
133  // start value drops to < 75% of maximum (try to avoid
134  // unnecessary searches for the mode)
135  //
136  if ( theModeStatus==Valid &&
137  (*i).first/(*xStart.begin()).first<0.75 ) break;
138  //
139  // Try to find mode
140  //
141  double x;
142  double y;
143  bool valid = findMode(x,y,mean((*i).second),standardDeviation((*i).second));
144  //
145  // consider only successful searches
146  //
147  if ( valid ) { //...
148  //
149  // update result only for significant changes in pdf(solution)
150  //
151  if ( yRes<0. || (y-yRes)/(y+yRes)>1.e-10 ) {
152  iRes = (*i).second; // store index
153  theModeStatus = Valid; // update status
154  xRes = x; // current solution
155  yRes = y; // and its pdf value
156 // result = std::make_pair(y,x); // store solution and pdf(solution)
157  }
158  } //...
159  }
160  //
161  // check (existance of) solution
162  //
163  if ( theModeStatus== Valid ) {
164  //
165  // Construct single Gaussian state with
166  // mean = mode
167  // variance = local variance at mode
168  // weight such that the pdf's of the mixture and the
169  // single state are equal at the mode
170  //
171  double mode = xRes;
172  double varMode = localVariance(mode);
173  double wgtMode = pdf(mode)*sqrt(2*M_PI*varMode);
174  theMode = SingleGaussianState1D(mode,varMode,wgtMode);
175  }
176  else {
177  //
178  // mode finding failed: set solution to highest component
179  // (alternative would be global mean / variance ..?)
180  //
181  //two many log warnings to actually be useful - comment out
182  //edm::LogWarning("GaussianSumUtilities") << "1D mode calculation failed";
183 // double x = mean();
184 // double y = pdf(x);
185 // result = std::make_pair(y,x);
186 // theMode = SingleGaussianState1D(mean(),variance(),weight());
187  //
188  // look for component with highest value at mean
189  //
190  int icMax(0);
191  double ySqMax(0.);
192  int s = size();
193  for (int ic=0; ic<s; ++ic ) {
194  double w = weight(ic);
195  double ySq = w*w/variance(ic);
196  if ( ySq>ySqMax ) {
197  icMax = ic;
198  ySqMax = ySq;
199  }
200  }
202  }
203 
204 }
int i
Definition: DBlmapReader.cc:9
double weight() const
combined weight
SingleGaussianState1D theMode
bool findMode(double &mode, double &pdfAtMode, const double &xStart, const double &scale) const
unsigned int size() const
number of components
U second(std::pair< T, U > const &p)
T sqrt(T t)
Definition: SSEVec.h:28
double variance() const
combined covariance
const SingleGaussianState1D & mode() const
double pdf(unsigned int i, double x) const
pdf of a single component at x
bool first
Definition: L1TdeRCT.cc:79
double mean() const
combined mean
#define M_PI
Definition: BFit3D.cc:3
double localVariance(double x) const
double standardDeviation(unsigned int i) const
standard deviation of a component
string s
Definition: asciidump.py:422
const std::vector< SingleGaussianState1D > & components() const
components
double GaussianSumUtilities1D::d1LnPdf ( const double &  x) const

first derivative of ln(pdf)

Definition at line 314 of file GaussianSumUtilities1D.cc.

References pdfComponents().

Referenced by d2LnPdf().

315 {
316  return d1LnPdf(x,pdfComponents(x));
317 }
std::vector< double > pdfComponents(const double &) const
pdf components
double d1LnPdf(const double &) const
first derivative of ln(pdf)
double GaussianSumUtilities1D::d1LnPdf ( double  x,
const std::vector< double > &  pdfs 
) const
private

first derivative of ln(pdf) using the pdf components at the evaluation point

Definition at line 414 of file GaussianSumUtilities1D.cc.

References d1Pdf(), f, min, pdf(), and query::result.

415 {
416 
417  double f = pdf(x,pdfs);
418  double result(d1Pdf(x,pdfs));
420  else result = 0.;
421  return result;
422 }
#define min(a, b)
Definition: mlp_lapack.h:161
double d1Pdf(const double &) const
first derivative of the p.d.f.
tuple result
Definition: query.py:137
double f[11][100]
double pdf(unsigned int i, double x) const
pdf of a single component at x
double GaussianSumUtilities1D::d1Pdf ( const double &  x) const

first derivative of the p.d.f.

Definition at line 290 of file GaussianSumUtilities1D.cc.

References pdfComponents().

Referenced by d1LnPdf(), and update().

291 {
292  return d1Pdf(x,pdfComponents(x));
293 }
std::vector< double > pdfComponents(const double &) const
pdf components
double d1Pdf(const double &) const
first derivative of the p.d.f.
double GaussianSumUtilities1D::d1Pdf ( double  x,
const std::vector< double > &  pdfs 
) const
private

first derivative of the p.d.f. using the pdf components at the evaluation point

Definition at line 368 of file GaussianSumUtilities1D.cc.

References i, mean(), query::result, asciidump::s, size(), and standardDeviation().

369 {
370  double result(0.);
371  size_t s=size();
372  for ( unsigned int i=0; i<s; i++ ) {
373  double dx = (x-mean(i))/standardDeviation(i);
374  result += -pdfs[i]*dx/standardDeviation(i);
375  }
376  return result;
377 }
int i
Definition: DBlmapReader.cc:9
unsigned int size() const
number of components
tuple result
Definition: query.py:137
double mean() const
combined mean
double standardDeviation(unsigned int i) const
standard deviation of a component
string s
Definition: asciidump.py:422
double GaussianSumUtilities1D::d2LnPdf ( const double &  x) const

second derivative of ln(pdf)

Definition at line 320 of file GaussianSumUtilities1D.cc.

References pdfComponents().

321 {
322  return d2LnPdf(x,pdfComponents(x));
323 }
std::vector< double > pdfComponents(const double &) const
pdf components
double d2LnPdf(const double &) const
second derivative of ln(pdf)
double GaussianSumUtilities1D::d2LnPdf ( double  x,
const std::vector< double > &  pdfs 
) const
private

second derivative of ln(pdf) using the pdf components at the evaluation point

Definition at line 425 of file GaussianSumUtilities1D.cc.

References d1LnPdf(), d2Pdf(), f, min, pdf(), and query::result.

426 {
427 
428  double f = pdf(x,pdfs);
429  double df = d1LnPdf(x,pdfs);
430  double result(-df*df);
431  if ( f>std::numeric_limits<double>::min() ) result += d2Pdf(x,pdfs)/f;
432  return result;
433 }
double d2Pdf(const double &) const
second derivative of the p.d.f.
#define min(a, b)
Definition: mlp_lapack.h:161
tuple result
Definition: query.py:137
double f[11][100]
double pdf(unsigned int i, double x) const
pdf of a single component at x
double d1LnPdf(const double &) const
first derivative of ln(pdf)
double GaussianSumUtilities1D::d2Pdf ( const double &  x) const

second derivative of the p.d.f.

Definition at line 296 of file GaussianSumUtilities1D.cc.

References pdfComponents().

Referenced by d2LnPdf(), localVariance(), and update().

297 {
298  return d2Pdf(x,pdfComponents(x));
299 }
std::vector< double > pdfComponents(const double &) const
pdf components
double d2Pdf(const double &) const
second derivative of the p.d.f.
double GaussianSumUtilities1D::d2Pdf ( double  x,
const std::vector< double > &  pdfs 
) const
private

second derivative of the p.d.f. using the pdf components at the evaluation point

Definition at line 380 of file GaussianSumUtilities1D.cc.

References i, mean(), query::result, asciidump::s, size(), and standardDeviation().

381 {
382  double result(0.);
383  size_t s=size();
384  for ( unsigned int i=0; i<s; i++ ) {
385  double dx = (x-mean(i))/standardDeviation(i);
386  result += pdfs[i]/standardDeviation(i)/standardDeviation(i)*(dx*dx-1);
387  }
388  return result;
389 }
int i
Definition: DBlmapReader.cc:9
unsigned int size() const
number of components
tuple result
Definition: query.py:137
double mean() const
combined mean
double standardDeviation(unsigned int i) const
standard deviation of a component
string s
Definition: asciidump.py:422
double GaussianSumUtilities1D::d3Pdf ( const double &  x) const

third derivative of the p.d.f.

Definition at line 302 of file GaussianSumUtilities1D.cc.

References pdfComponents().

303 {
304  return d3Pdf(x,pdfComponents(x));
305 }
std::vector< double > pdfComponents(const double &) const
pdf components
double d3Pdf(const double &) const
third derivative of the p.d.f.
double GaussianSumUtilities1D::d3Pdf ( double  x,
const std::vector< double > &  pdfs 
) const
private

third derivative of the p.d.f. using the pdf components at the evaluation point

Definition at line 392 of file GaussianSumUtilities1D.cc.

References i, mean(), query::result, asciidump::s, size(), and standardDeviation().

393 {
394  double result(0.);
395  size_t s=size();
396  for ( unsigned int i=0; i<s; i++ ) {
397  double dx = (x-mean(i))/standardDeviation(i);
399  (-dx*dx+3)*dx;
400  }
401  return result;
402 }
int i
Definition: DBlmapReader.cc:9
unsigned int size() const
number of components
tuple result
Definition: query.py:137
double mean() const
combined mean
double standardDeviation(unsigned int i) const
standard deviation of a component
string s
Definition: asciidump.py:422
bool GaussianSumUtilities1D::findMode ( double &  mode,
double &  pdfAtMode,
const double &  xStart,
const double &  scale 
) const
private

Finds mode. Input: start value and typical scale. Output: mode and pdf(mode). Return value is true on success.

Definition at line 207 of file GaussianSumUtilities1D.cc.

References min, query::result, size(), evf::utils::state, update(), GaussianSumUtilities1D::FinderState::x, GaussianSumUtilities1D::FinderState::y, GaussianSumUtilities1D::FinderState::yd, and GaussianSumUtilities1D::FinderState::yd2.

Referenced by computeMode().

210 {
211  //
212  // try with Newton on (lnPdf)'(x)
213  //
214  double x1(0.);
215  double y1(0.);
216  FinderState state(size());
217  update(state,xStart);
218 
219  double xmin(xStart-1.*scale);
220  double xmax(xStart+1.*scale);
221  //
222  // preset result
223  //
224  bool result(false);
225  xMode = state.x;
226  yMode = state.y;
227  //
228  // Iterate
229  //
230  int nLoop(0);
231  while ( nLoop++<20 ) {
232  if ( nLoop>1 && state.yd2<0. &&
233  ( fabs(state.yd*scale)<1.e-10 || fabs(state.y-y1)/(state.y+y1)<1.e-14 ) ) {
234  result = true;
235  break;
236  }
237  if ( fabs(state.yd2)<std::numeric_limits<float>::min() )
238  state.yd2 = state.yd2>0. ? std::numeric_limits<float>::min() : -std::numeric_limits<float>::min();
239  double dx = -state.yd/state.yd2;
240  x1 = state.x;
241  y1 = state.y;
242  double x2 = x1 + dx;
243  if ( state.yd2>0. && (x2<xmin||x2>xmax) ) return false;
244  update(state,x2);
245  }
246  //
247  // result
248  //
249  if ( result ) {
250  xMode = state.x;
251  yMode = state.y;
252  }
253  return result;
254 }
#define min(a, b)
Definition: mlp_lapack.h:161
unsigned int size() const
number of components
tuple result
Definition: query.py:137
char state
Definition: procUtils.cc:75
void update(FinderState &state, double x) const
double GaussianSumUtilities1D::gauss ( double  x,
double  mean,
double  sigma 
)
staticprivate

Value of gaussian distribution.

Definition at line 436 of file GaussianSumUtilities1D.cc.

Referenced by pdf(), and pdfComponents().

437 {
438 // const double fNorm(1./sqrt(2*M_PI));
439 // double result(0.);
440 
441 // double d((x-mean)/sigma);
442 // if ( fabs(d)<20. ) result = exp(-d*d/2.);
443 // result *= fNorm/sigma;
444 // return result;
445  return ROOT::Math::gaussian_pdf(x,sigma,mean);
446 }
double mean() const
combined mean
double GaussianSumUtilities1D::gaussInt ( double  x,
double  mean,
double  sigma 
)
staticprivate

Integrated value of gaussian distribution.

Definition at line 449 of file GaussianSumUtilities1D.cc.

Referenced by cdf().

double GaussianSumUtilities1D::lnPdf ( const double &  x) const

ln(pdf)

Definition at line 308 of file GaussianSumUtilities1D.cc.

References pdfComponents().

309 {
310  return lnPdf(x,pdfComponents(x));
311 }
std::vector< double > pdfComponents(const double &) const
pdf components
double lnPdf(const double &) const
ln(pdf)
double GaussianSumUtilities1D::lnPdf ( double  x,
const std::vector< double > &  pdfs 
)
staticprivate

ln(pdf) using the pdf components at the evaluation point

Definition at line 405 of file GaussianSumUtilities1D.cc.

References f, funct::log(), max(), min, pdf(), and query::result.

406 {
407  double f(pdf(x,pdfs));
410  return result;
411 }
#define min(a, b)
Definition: mlp_lapack.h:161
const T & max(const T &a, const T &b)
tuple result
Definition: query.py:137
double f[11][100]
double pdf(unsigned int i, double x) const
pdf of a single component at x
Log< T >::type log(const T &t)
Definition: Log.h:22
double GaussianSumUtilities1D::localVariance ( double  x) const
private

Local variance from Hessian matrix. Only valid if x corresponds to a (local) maximum!

Definition at line 469 of file GaussianSumUtilities1D.cc.

References d2Pdf(), pdf(), pdfComponents(), and query::result.

Referenced by computeMode().

470 {
471  std::vector<double> pdfs;
472  pdfComponents(x,pdfs);
473  double result = -pdf(x,pdfs)/d2Pdf(x,pdfs);
474  // FIXME: wrong curvature seems to be non-existant but should add a proper recovery
475  if ( result<0. )
476  edm::LogWarning("GaussianSumUtilities") << "1D variance at mode < 0";
477  return result;
478 }
std::vector< double > pdfComponents(const double &) const
pdf components
double d2Pdf(const double &) const
second derivative of the p.d.f.
tuple result
Definition: query.py:137
double pdf(unsigned int i, double x) const
pdf of a single component at x
double GaussianSumUtilities1D::mean ( unsigned int  i) const
inline
double GaussianSumUtilities1D::mean ( ) const
inline

combined mean

Definition at line 75 of file GaussianSumUtilities1D.h.

References MultiGaussianState1D::mean(), and theState.

Referenced by cdf(), computeMode(), d1Pdf(), d2Pdf(), d3Pdf(), pdf(), and pdfComponents().

75  {
76  return theState.mean();
77  }
const MultiGaussianState1D & theState
double mean() const
combined mean
const SingleGaussianState1D & GaussianSumUtilities1D::mode ( void  ) const
bool GaussianSumUtilities1D::modeIsValid ( ) const
double GaussianSumUtilities1D::pdf ( unsigned int  i,
double  x 
) const

pdf of a single component at x

Definition at line 22 of file GaussianSumUtilities1D.cc.

References gauss(), mean(), standardDeviation(), and weight().

Referenced by computeMode(), d1LnPdf(), d2LnPdf(), lnPdf(), localVariance(), pdf(), and update().

22  {
23  return weight(i)*gauss(x,mean(i),standardDeviation(i));
24 }
int i
Definition: DBlmapReader.cc:9
double weight() const
combined weight
static double gauss(double, double, double)
Value of gaussian distribution.
double mean() const
combined mean
double standardDeviation(unsigned int i) const
standard deviation of a component
double GaussianSumUtilities1D::pdf ( double  x) const

value of the p.d.f.

Definition at line 270 of file GaussianSumUtilities1D.cc.

References i, pdf(), query::result, asciidump::s, and size().

271 {
272  double result(0.);
273  size_t s=size();
274  for ( unsigned int i=0; i<s; i++ )
275  result += pdf(i,x);
276  return result;
277 }
int i
Definition: DBlmapReader.cc:9
unsigned int size() const
number of components
tuple result
Definition: query.py:137
double pdf(unsigned int i, double x) const
pdf of a single component at x
string s
Definition: asciidump.py:422
double GaussianSumUtilities1D::pdf ( double  ,
const std::vector< double > &  pdfs 
)
staticprivate

value of the p.d.f. using the pdf components at the evaluation point

Definition at line 362 of file GaussianSumUtilities1D.cc.

363 {
364  return std::accumulate(pdfs.begin(),pdfs.end(),0.);
365 }
std::vector< double > GaussianSumUtilities1D::pdfComponents ( const double &  x) const
private

pdf components

Definition at line 326 of file GaussianSumUtilities1D.cc.

References gauss(), i, mean(), query::result, size(), standardDeviation(), and weight().

Referenced by d1LnPdf(), d1Pdf(), d2LnPdf(), d2Pdf(), d3Pdf(), lnPdf(), localVariance(), and update().

327 {
328  std::vector<double> result;
329  result.reserve(size());
330  for ( unsigned int i=0; i<size(); i++ )
331  result.push_back(weight(i)*gauss(x,mean(i),standardDeviation(i)));
332  return result;
333 }
int i
Definition: DBlmapReader.cc:9
double weight() const
combined weight
static double gauss(double, double, double)
Value of gaussian distribution.
unsigned int size() const
number of components
tuple result
Definition: query.py:137
double mean() const
combined mean
double standardDeviation(unsigned int i) const
standard deviation of a component
void GaussianSumUtilities1D::pdfComponents ( double  x,
std::vector< double > &  result 
) const
private

pdf components

Definition at line 344 of file GaussianSumUtilities1D.cc.

References begin, components(), end, asciidump::s, and size().

344  {
345  size_t s = size();
346  if (s!=result.size()) result.resize(s);
347  std::transform(components().begin(),components().end(),result.begin(),PDF(x));
348 }
unsigned int size() const
number of components
tuple result
Definition: query.py:137
#define end
Definition: vmac.h:38
#define begin
Definition: vmac.h:31
string s
Definition: asciidump.py:422
const std::vector< SingleGaussianState1D > & components() const
components
double GaussianSumUtilities1D::quantile ( const double  q) const

Quantile (i.e. x for a given value of the c.d.f.)

Definition at line 28 of file GaussianSumUtilities1D.cc.

29 {
30  return ROOT::Math::gaussian_quantile(q,1.);
31 }
unsigned int GaussianSumUtilities1D::size ( void  ) const
inline

number of components

Definition at line 28 of file GaussianSumUtilities1D.h.

References components().

Referenced by cdf(), combinedMean(), computeMode(), d1Pdf(), d2Pdf(), d3Pdf(), findMode(), pdf(), and pdfComponents().

28 {return components().size();}
const std::vector< SingleGaussianState1D > & components() const
components
double GaussianSumUtilities1D::standardDeviation ( unsigned int  i) const
inline

standard deviation of a component

Definition at line 38 of file GaussianSumUtilities1D.h.

References components(), and i.

Referenced by cdf(), computeMode(), d1Pdf(), d2Pdf(), d3Pdf(), pdf(), and pdfComponents().

38  {
39 // return sqrt(components()[i].variance());
40  return components()[i].standardDeviation();
41  }
int i
Definition: DBlmapReader.cc:9
const std::vector< SingleGaussianState1D > & components() const
components
void GaussianSumUtilities1D::update ( FinderState state,
double  x 
) const
private

Definition at line 257 of file GaussianSumUtilities1D.cc.

References d1Pdf(), d2Pdf(), min, pdf(), pdfComponents(), GaussianSumUtilities1D::FinderState::pdfs, GaussianSumUtilities1D::FinderState::x, ExpressReco_HICollisions_FallBack::x, GaussianSumUtilities1D::FinderState::y, GaussianSumUtilities1D::FinderState::yd, and GaussianSumUtilities1D::FinderState::yd2.

Referenced by python.Vispa.Gui.VispaWidget.VispaWidget::autosize(), python.Vispa.Views.LineDecayView.LineDecayContainer::createObject(), python.Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), python.Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), findMode(), python.Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), python.Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), python.Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), python.Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), python.Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), python.Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), python.Vispa.Gui.FindDialog.FindDialog::reset(), python.Vispa.Gui.PortConnection.PointToPointConnection::select(), python.Vispa.Gui.VispaWidget.VispaWidget::select(), python.Vispa.Views.LineDecayView.LineDecayContainer::select(), python.Vispa.Gui.VispaWidget.VispaWidget::setText(), python.Vispa.Gui.VispaWidget.VispaWidget::setTitle(), python.Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), python.Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and python.Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

257  {
258  state.x = x;
259 
260  pdfComponents(state.x, state.pdfs);
261  state.y = pdf(state.x, state.pdfs);
262  state.yd = 0;
264  state.yd2 = -state.yd*state.yd;
265  if (state.y > std::numeric_limits<double>::min()) state.yd2 += d2Pdf(state.x,state.pdfs)/state.y;
266 }
std::vector< double > pdfComponents(const double &) const
pdf components
double d2Pdf(const double &) const
second derivative of the p.d.f.
#define min(a, b)
Definition: mlp_lapack.h:161
double d1Pdf(const double &) const
first derivative of the p.d.f.
double pdf(unsigned int i, double x) const
pdf of a single component at x
char state
Definition: procUtils.cc:75
double GaussianSumUtilities1D::variance ( unsigned int  i) const
inline

variance of a component

Definition at line 43 of file GaussianSumUtilities1D.h.

References components(), and i.

Referenced by GsfTrackProducerBase::fillMode().

43 {return components()[i].variance();}
int i
Definition: DBlmapReader.cc:9
const std::vector< SingleGaussianState1D > & components() const
components
double GaussianSumUtilities1D::variance ( ) const
inline

combined covariance

Definition at line 79 of file GaussianSumUtilities1D.h.

References theState, and MultiGaussianState1D::variance().

Referenced by computeMode().

79  {
80  return theState.variance();
81  }
const MultiGaussianState1D & theState
double variance() const
combined variance
double GaussianSumUtilities1D::weight ( unsigned int  i) const
inline

weight of a component

Definition at line 34 of file GaussianSumUtilities1D.h.

References components(), and i.

34 {return components()[i].weight();}
int i
Definition: DBlmapReader.cc:9
const std::vector< SingleGaussianState1D > & components() const
components
double GaussianSumUtilities1D::weight ( ) const
inline

combined weight

Definition at line 71 of file GaussianSumUtilities1D.h.

References theState, and MultiGaussianState1D::weight().

Referenced by cdf(), combinedMean(), computeMode(), pdf(), and pdfComponents().

71  {
72  return theState.weight();
73  }
const MultiGaussianState1D & theState
double weight() const
combined weight

Member Data Documentation

SingleGaussianState1D GaussianSumUtilities1D::theMode
mutableprivate

Definition at line 139 of file GaussianSumUtilities1D.h.

Referenced by computeMode(), and mode().

ModeStatus GaussianSumUtilities1D::theModeStatus
mutableprivate

Definition at line 138 of file GaussianSumUtilities1D.h.

Referenced by computeMode(), mode(), and modeIsValid().

const MultiGaussianState1D& GaussianSumUtilities1D::theState
private

Definition at line 135 of file GaussianSumUtilities1D.h.

Referenced by components(), mean(), variance(), and weight().