CMS 3D CMS Logo

Public Member Functions | Private Attributes

BinomialProbability Class Reference

#include <BinomialProbability.h>

List of all members.

Public Member Functions

 BinomialProbability ()
 BinomialProbability (int hits, int entries)
int entries () const
float error () const
void hit ()
int hits () const
void miss ()
void update (bool hit)
float value () const

Private Attributes

int theHits
int theTotal

Detailed Description

A simple class for accumulating binomial "events", i.e. events that have a yes/no outcome, and for computing the binomial error on the fraction of positive hits.

Definition at line 10 of file BinomialProbability.h.


Constructor & Destructor Documentation

BinomialProbability::BinomialProbability ( ) [inline]

Definition at line 13 of file BinomialProbability.h.

: theHits(0), theTotal(0) {}
BinomialProbability::BinomialProbability ( int  hits,
int  entries 
) [inline]

Definition at line 15 of file BinomialProbability.h.


Member Function Documentation

int BinomialProbability::entries ( ) const [inline]

Definition at line 27 of file BinomialProbability.h.

References theTotal.

{ return theTotal;}
float BinomialProbability::error ( ) const [inline]

Definition at line 22 of file BinomialProbability.h.

References f, AlCaHLTBitMon_ParallelJobs::p, mathSSE::sqrt(), theTotal, and value().

                      {
    float p = value();
    return theTotal <= 1 ? 0 : sqrt( p*(1.f - p)/(theTotal-1));
  }
void BinomialProbability::hit ( void  ) [inline]

Definition at line 31 of file BinomialProbability.h.

References theHits, and theTotal.

{ theHits++; theTotal++;}
int BinomialProbability::hits ( ) const [inline]

Definition at line 29 of file BinomialProbability.h.

References theHits.

{ return theHits;}
void BinomialProbability::miss ( ) [inline]

Definition at line 33 of file BinomialProbability.h.

References theTotal.

{ theTotal++;}
void BinomialProbability::update ( bool  hit) [inline]

Definition at line 35 of file BinomialProbability.h.

References theHits, and theTotal.

                         {
    if ( hit) theHits++;
    theTotal++;
  }
float BinomialProbability::value ( ) const [inline]

Definition at line 18 of file BinomialProbability.h.

References theHits, and theTotal.

Referenced by error().

                      {
    return theTotal == 0 ? 0 :float(theHits) / float(theTotal);
  }

Member Data Documentation

Definition at line 42 of file BinomialProbability.h.

Referenced by hit(), hits(), update(), and value().

Definition at line 43 of file BinomialProbability.h.

Referenced by entries(), error(), hit(), miss(), update(), and value().