Belle II Software development
EmpiricalDistributionFunction Class Reference

Empirical distribution function object is basic for mainpulation of probabilities. More...

#include <NNWaveFitTool.h>

Public Member Functions

 EmpiricalDistributionFunction (const nnFitterBinData &p, const nnFitterBins &bins)
 Constructor constructs edf object from a probability distribution.
 
double operator() (double t)
 EmpiricalDistributionFunction(t) gives edf value at time t, linearly interpolated from cummulative bin probabilities.
 

Private Attributes

const nnFitterBinsm_bins
 array of bin boundaries.
 
std::vector< std::pair< double, double > > m_pTable
 (bin, prob) pairs
 

Detailed Description

Empirical distribution function object is basic for mainpulation of probabilities.

Definition at line 39 of file NNWaveFitTool.h.

Constructor & Destructor Documentation

◆ EmpiricalDistributionFunction()

EmpiricalDistributionFunction ( const nnFitterBinData p,
const nnFitterBins bins 
)
inline

Constructor constructs edf object from a probability distribution.

Parameters
parray of bin probabilities
binsarray of bin boundaries, size(p) + 1

Definition at line 45 of file NNWaveFitTool.h.

45 :
46 m_bins(bins)
47 {
48 // Create table of probabiilities for EmpiricalDistributionFunction calculation
49 m_pTable.resize(m_bins.size());
50 auto ibin = m_bins.begin();
51 auto ipt = m_pTable.begin();
52 double cp = 0.0;
53 *ipt++ = std::make_pair(*ibin++, cp);
54 for (auto prob : p) {
55 cp += prob;
56 *ipt++ = std::make_pair(*ibin++, cp);
57 }
58 }
std::vector< std::pair< double, double > > m_pTable
(bin, prob) pairs
Definition: NNWaveFitTool.h:79
const nnFitterBins & m_bins
array of bin boundaries.
Definition: NNWaveFitTool.h:78

Member Function Documentation

◆ operator()()

double operator() ( double  t)
inline

EmpiricalDistributionFunction(t) gives edf value at time t, linearly interpolated from cummulative bin probabilities.

Parameters
ttime at which edf is to be calculated.

Definition at line 64 of file NNWaveFitTool.h.

65 {
66 // pTable is sorted by .first
67 if (t > m_pTable.back().first) return 1.0;
68 if (t < m_pTable[0].first) return 0.0;
69 auto it = lower_bound(m_pTable.begin(), m_pTable.end(), std::make_pair(t, 0.0));
70 if (it == m_pTable.begin()) return it->second;
71 auto it2 = it;
72 --it2;
73 double result = it2->second + (it->second - it2->second) * (t - it2->first) / (it->first - it2->first);
74 return result;
75 }

Member Data Documentation

◆ m_bins

const nnFitterBins& m_bins
private

array of bin boundaries.

Definition at line 78 of file NNWaveFitTool.h.

◆ m_pTable

std::vector<std::pair<double, double> > m_pTable
private

(bin, prob) pairs

Definition at line 79 of file NNWaveFitTool.h.


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