Public Member Functions | Private Attributes | List of all members
util::NormalDistribution Class Reference

#include <PIDAAlg.h>

Public Member Functions

 NormalDistribution ()
 
 NormalDistribution (float, float)
 
float getValue (float)
 

Private Attributes

float fStepSize
 
float fMaxSigma
 
std::vector< float > fValues
 

Detailed Description

Definition at line 26 of file PIDAAlg.h.

Constructor & Destructor Documentation

util::NormalDistribution::NormalDistribution ( )
inline

Definition at line 29 of file PIDAAlg.h.

29 {}
util::NormalDistribution::NormalDistribution ( float  max_sigma,
float  step_size 
)

Definition at line 341 of file PIDAAlg.cxx.

341  {
342 
343  if(step_size==0)
344  throw "util::NormalDistribution --- Cannot have zero step size!";
345 
346  const size_t vector_size = (size_t)(max_sigma / step_size);
347  fValues.resize(vector_size);
348 
349  const float AMPLITUDE = 1. / std::sqrt(2*M_PI);
350 
351  float integral=0;
352  for(size_t i_step=0; i_step<vector_size; i_step++){
353  float diff = i_step*step_size;
354  fValues[i_step] = AMPLITUDE * std::exp(-0.5*diff*diff);
355  integral+= fValues[i_step];
356  }
357 
358  for(size_t i_step=0; i_step<vector_size; i_step++)
359  fValues[i_step] /= (integral*2);
360 
361  fStepSize = step_size;
362  fMaxSigma = fStepSize * vector_size;
363 
364 }
std::vector< float > fValues
Definition: PIDAAlg.h:37
#define M_PI
Definition: includeROOT.h:54

Member Function Documentation

float util::NormalDistribution::getValue ( float  x)

Definition at line 366 of file PIDAAlg.cxx.

366  {
367 
368  x = std::abs(x);
369  if(x > fMaxSigma) return 0;
370 
371  size_t bin_low = x / fStepSize;
372  float remainder = (x - (bin_low*fStepSize)) / fStepSize;
373 
374  return fValues[bin_low]*(1-remainder) + remainder*fValues[bin_low+1];
375 
376 }
T abs(T value)
std::vector< float > fValues
Definition: PIDAAlg.h:37
list x
Definition: train.py:276

Member Data Documentation

float util::NormalDistribution::fMaxSigma
private

Definition at line 36 of file PIDAAlg.h.

float util::NormalDistribution::fStepSize
private

Definition at line 35 of file PIDAAlg.h.

std::vector<float> util::NormalDistribution::fValues
private

Definition at line 37 of file PIDAAlg.h.


The documentation for this class was generated from the following files: