Public Member Functions | Private Attributes | Friends
mbl_sum_1d Class Reference

Computes running sum of 1D variable, so mean accessible. More...

#include <mbl_sum_1d.h>

List of all members.

Public Member Functions

 mbl_sum_1d ()
void clear ()
 Remove all data.
void obs (double v)
 Add given observation.
int nObs () const
 Number of observations.
double mean () const
 Mean of current observations.
double sum () const
 Sum of current observations.
mbl_sum_1doperator+= (const mbl_sum_1d &s1)
 Add statistics together.
void print_summary (vcl_ostream &os) const
short version_no () const
 Version number for I/O.
void b_write (vsl_b_ostream &bfs) const
void b_read (vsl_b_istream &bfs)
bool operator== (const mbl_sum_1d &s) const
 Test for equality.

Private Attributes

double sum_
int n_obs_

Friends

mbl_sum_1d operator+ (const mbl_sum_1d &s1, const mbl_sum_1d &s2)

Detailed Description

Computes running sum of 1D variable, so mean accessible.

   // A rather trivial example
   mbl_sum_1d stats,stats2;

   const int n = 10;
   for (int i=0;i<n;i++)
   {
     stats.obs(i);
     stats.obs(i+10);
   }

   vcl_cout<<stats;
   vcl_cout<<"Mean of numbers 0..9:"<<stats.mean()<<vcl_endl;
   mbl_sum_1d stats3 = stats+stats2;
   vcl_cout<<"Mean of numbers 0..19:"<<stats3.mean()<<vcl_endl;

Definition at line 29 of file mbl_sum_1d.h.


Constructor & Destructor Documentation

mbl_sum_1d::mbl_sum_1d ( )

Definition at line 11 of file mbl_sum_1d.cxx.


Member Function Documentation

void mbl_sum_1d::b_read ( vsl_b_istream bfs)

Definition at line 51 of file mbl_sum_1d.cxx.

void mbl_sum_1d::b_write ( vsl_b_ostream bfs) const

Definition at line 44 of file mbl_sum_1d.cxx.

void mbl_sum_1d::clear ( )

Remove all data.

Definition at line 16 of file mbl_sum_1d.cxx.

double mbl_sum_1d::mean ( ) const [inline]

Mean of current observations.

Definition at line 46 of file mbl_sum_1d.h.

int mbl_sum_1d::nObs ( ) const [inline]

Number of observations.

Definition at line 43 of file mbl_sum_1d.h.

void mbl_sum_1d::obs ( double  v) [inline]

Add given observation.

Definition at line 40 of file mbl_sum_1d.h.

mbl_sum_1d & mbl_sum_1d::operator+= ( const mbl_sum_1d s1)

Add statistics together.

Definition at line 22 of file mbl_sum_1d.cxx.

bool mbl_sum_1d::operator== ( const mbl_sum_1d s) const

Test for equality.

Definition at line 32 of file mbl_sum_1d.cxx.

void mbl_sum_1d::print_summary ( vcl_ostream &  os) const

Definition at line 72 of file mbl_sum_1d.cxx.

double mbl_sum_1d::sum ( ) const [inline]

Sum of current observations.

Definition at line 49 of file mbl_sum_1d.h.

short mbl_sum_1d::version_no ( ) const

Version number for I/O.

Definition at line 39 of file mbl_sum_1d.cxx.


Friends And Related Function Documentation

mbl_sum_1d operator+ ( const mbl_sum_1d s1,
const mbl_sum_1d s2 
) [friend]

Definition at line 95 of file mbl_sum_1d.cxx.


Member Data Documentation

int mbl_sum_1d::n_obs_ [private]

Definition at line 32 of file mbl_sum_1d.h.

double mbl_sum_1d::sum_ [private]

Definition at line 31 of file mbl_sum_1d.h.


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