Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

RazorBack::Distrapprox_ Class Reference

#include <Distrapprox.hh>

Inheritance diagram for RazorBack::Distrapprox_:

Inheritance graph
[legend]
Collaboration diagram for RazorBack::Distrapprox_:

Collaboration graph
[legend]
List of all members.

Public Methods

 Distrapprox_ (double W)
 Constructs an object so that it is ready to do an approximation with a bin width W. More...

void reset (double W)
 reset(W): Resets the calling object so that it is ready to do an approximation with a bin width W. More...

void clear ()
 clear(): clears the calling object. More...

Distrapprox_& operator+= (double X)
 +=: adds the value X (a sample from the distribution to be approximated).

void evaluate ()
 evaluate(): normalise the counts and make the PDF and CDF.

double low () const
 Returns the lowest value covered by the approximation. More...

double high () const
 Returns the highest value covered by the approximation. More...

virtual double pdf (double X) const
 Returns a linearly interpolated value for the PDF. More...

virtual double cdf (double X) const
 Returns a linearly interpolated value for the CDF. More...

virtual double inv_cdf (double Y) const
 Returns an interpolated value for the inverse CDF, X where CDF(X)=Y. More...

virtual double mean () const
 Returns the estimated mean of the distribution.

virtual double var () const
 Returns the estimated variance of the distribution.

virtual double skew () const
 Returns the skewness of the distribution.

virtual double kurt () const
 Returns the kurtosis of the distribution.

virtual double entropy () const
 entropy(): approximates the entropy of the distribution. More...

virtual double random (void) const
 random(): returns a random value from the approximated distribution.


Protected Types

typedef list<Bin_>::iterator Biniter_

Protected Methods

int bin_index (double X) const
double bin_midpoint (unsigned int Idx) const
int locate_index (double X) const
double lin_intp (double X, const vector< double > &YY, double YYmax) const

Private Attributes

list<Bin_Binlist
 histogram bins sorted in increasing center order.

double Width
 bin width.

vector<double> Pdf
 approximation of PDF.

vector<double> Cdf
 approximation of CDF.

unsigned int Binno
 length of Pdf and Cdf.

double Low
double High
 lowest and highest X value covered by the bins.

bool Dirty
 true when a new value is added.

Randomuni_ Rand
 uniform random number generator.

Stat_ Stat
 statistics for average and SD.


Friends

ostream& operator<< (ostream &Out, const Distrapprox_ &D)
 Writes (serializes) a Distrapprox_ object to Out. More...

istream& operator>> (istream &In, Distrapprox_ &D)
 Reads (deserializes) a Distrapprox_ object from In. More...


Member Typedef Documentation

typedef list<Bin_>::iterator RazorBack::Distrapprox_::Biniter_ [protected]
 

Definition at line 101 of file Distrapprox.hh.


Constructor & Destructor Documentation

RazorBack::Distrapprox_::Distrapprox_ ( double W ) [inline, explicit]
 

Constructs an object so that it is ready to do an approximation with a bin width W.

If W<0.0, then its absolute value is used. If W==0.0, then a Badvalexc_ is thrown.

Definition at line 125 of file Distrapprox.hh.


Member Function Documentation

void RazorBack::Distrapprox_::reset ( double W )
 

reset(W): Resets the calling object so that it is ready to do an approximation with a bin width W.

All previous data are lost. If W<0.0, then its absolute value is used. If W==0.0, then a Badvalexc_ is thrown.

Referenced by Distrapprox_().

void RazorBack::Distrapprox_::clear ( )
 

clear(): clears the calling object.

All data are lost except the histogram bin width.

Distrapprox_ & RazorBack::Distrapprox_::operator+= ( double X )
 

+=: adds the value X (a sample from the distribution to be approximated).

void RazorBack::Distrapprox_::evaluate ( )
 

evaluate(): normalise the counts and make the PDF and CDF.

double RazorBack::Distrapprox_::low ( ) const [inline]
 

Returns the lowest value covered by the approximation.

Throws Forgottenexc_ if evaluate() was not invoked beforehand.

Definition at line 152 of file Distrapprox.hh.

double RazorBack::Distrapprox_::high ( ) const [inline]
 

Returns the highest value covered by the approximation.

Throws Forgottenexc_ if evaluate() was not invoked beforehand.

Definition at line 163 of file Distrapprox.hh.

double RazorBack::Distrapprox_::pdf ( double X ) const [inline, virtual]
 

Returns a linearly interpolated value for the PDF.

Throws Forgottenexc_ if evaluate() was not invoked beforehand.

Reimplemented from RazorBack::Distrbase_.

Definition at line 174 of file Distrapprox.hh.

double RazorBack::Distrapprox_::cdf ( double X ) const [inline, virtual]
 

Returns a linearly interpolated value for the CDF.

Throws Forgottenexc_ if evaluate() was not invoked beforehand.

Reimplemented from RazorBack::Distrbase_.

Definition at line 180 of file Distrapprox.hh.

double RazorBack::Distrapprox_::inv_cdf ( double Y ) const [virtual]
 

Returns an interpolated value for the inverse CDF, X where CDF(X)=Y.

Throws Forgottenexc_ if evaluate() was not invoked beforehand.

Reimplemented from RazorBack::Distrbase_.

Referenced by random().

double RazorBack::Distrapprox_::mean ( ) const [inline, virtual]
 

Returns the estimated mean of the distribution.

Reimplemented from RazorBack::Distrbase_.

Definition at line 189 of file Distrapprox.hh.

double RazorBack::Distrapprox_::var ( ) const [inline, virtual]
 

Returns the estimated variance of the distribution.

Reimplemented from RazorBack::Distrbase_.

Definition at line 192 of file Distrapprox.hh.

double RazorBack::Distrapprox_::skew ( ) const [inline, virtual]
 

Returns the skewness of the distribution.

Reimplemented from RazorBack::Distrbase_.

Definition at line 195 of file Distrapprox.hh.

double RazorBack::Distrapprox_::kurt ( ) const [inline, virtual]
 

Returns the kurtosis of the distribution.

Reimplemented from RazorBack::Distrbase_.

Definition at line 198 of file Distrapprox.hh.

double RazorBack::Distrapprox_::entropy ( ) const [virtual]
 

entropy(): approximates the entropy of the distribution.

Throws Forgottenexc_ if evaluate() was not invoked beforehand.

Reimplemented from RazorBack::Distrbase_.

double RazorBack::Distrapprox_::random ( void ) const [inline, virtual]
 

random(): returns a random value from the approximated distribution.

Reimplemented from RazorBack::Distrbase_.

Definition at line 207 of file Distrapprox.hh.

int RazorBack::Distrapprox_::bin_index ( double X ) const [inline, protected]
 

Definition at line 244 of file Distrapprox.hh.

double RazorBack::Distrapprox_::bin_midpoint ( unsigned int Idx ) const [inline, protected]
 

Definition at line 248 of file Distrapprox.hh.

int RazorBack::Distrapprox_::locate_index ( double X ) const [protected]
 

double RazorBack::Distrapprox_::lin_intp ( double X,
const vector< double > & YY,
double YYmax ) const [protected]
 

Referenced by cdf(), and pdf().


Friends And Related Function Documentation

ostream & operator<< ( ostream & Out,
const Distrapprox_ & D ) [friend]
 

Writes (serializes) a Distrapprox_ object to Out.

The format is:-

        DISTRAPPROX
        WIDTH = 0.1
        STAT
        N = 1000
        MIN = -4.7362
        MAX = 6.30655
        SUM = 957.413
        SUM2 = 4575.58
        SUM3 = 11291.8
        SUM4 = 57072.3
        ENDSTAT
        -47 1       <-- bin offset index and bin count, see Bin_
        -45 3
        ...
        61 2
        63 1
        ENDDISTRAPPROX
        

istream & operator>> ( istream & In,
Distrapprox_ & D ) [friend]
 

Reads (deserializes) a Distrapprox_ object from In.

See operator<< for a format description.


Member Data Documentation

list< Bin_ > RazorBack::Distrapprox_::Binlist<Bin_> [private]
 

histogram bins sorted in increasing center order.

Definition at line 106 of file Distrapprox.hh.

double RazorBack::Distrapprox_::Width [private]
 

bin width.

Definition at line 107 of file Distrapprox.hh.

vector< double > RazorBack::Distrapprox_::Pdf<double> [private]
 

approximation of PDF.

Definition at line 108 of file Distrapprox.hh.

vector< double > RazorBack::Distrapprox_::Cdf<double> [private]
 

approximation of CDF.

Definition at line 109 of file Distrapprox.hh.

unsigned int RazorBack::Distrapprox_::Binno [private]
 

length of Pdf and Cdf.

Definition at line 110 of file Distrapprox.hh.

double RazorBack::Distrapprox_::Low [private]
 

Definition at line 111 of file Distrapprox.hh.

double RazorBack::Distrapprox_::High [private]
 

lowest and highest X value covered by the bins.

Definition at line 111 of file Distrapprox.hh.

bool RazorBack::Distrapprox_::Dirty [private]
 

true when a new value is added.

Definition at line 112 of file Distrapprox.hh.

Randomuni_ RazorBack::Distrapprox_::Rand [private]
 

uniform random number generator.

Definition at line 113 of file Distrapprox.hh.

Referenced by random().

Stat_ RazorBack::Distrapprox_::Stat [private]
 

statistics for average and SD.

Definition at line 114 of file Distrapprox.hh.


The documentation for this class was generated from the following file:
Generated at Wed Aug 21 09:33:15 2002 for The Razorback C++ Library: Statistics by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001