Public Member Functions | Private Attributes
mbl_wt_histogram Class Reference

Simple object to build histogram from supplied data, with weights. More...

#include <mbl_wt_histogram.h>

List of all members.

Public Member Functions

 mbl_wt_histogram ()
 Construct with no bins.
 mbl_wt_histogram (double x_lo, double x_hi, int n_bins)
 Construct with given number of bins over given range.
void set_bins (double x_lo, double x_hi, int n_bins)
 Define number and size of bins.
void clear ()
 Remove all data.
void obs (double v, double wt)
 Add given observation.
int n_bins () const
 Number of bins.
double xlo () const
 Bin width. Bin i is given by [bin_t0()+i*dx(),bin_t0()+(i+1)*dx()).
double dx () const
 Bin width. Bin i is given by [bin_t0()+i*dx(),bin_t0()+(i+1)*dx()).
int n_obs () const
 Number of observations.
double total_wt () const
 Total sum of weights supplied.
const vcl_vector< double > & wt_sum () const
 Total weight in each bin.
double wt_below () const
 Total weight below lowest bin (bin_t0()).
double wt_above () const
 Total weight above highest bin (bin_t0()+(n_bins()-1) * dx()).
bool write_probabilities (const char *path)
 Write out probabilities (freq/wt) to a named file.
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_wt_histogram &s) const
 Test for equality.

Private Attributes

double xlo_
 Bin i is given by [xlo_+i*dx_,xlo_+(i+1)*dx_).
double dx_
 Bin width. Bin i is given by [xlo_+i*dx_,xlo_+(i+1)*dx_).
vcl_vector< double > wt_sum_
 Total weight in each bin.
double wt_below_
 Number below lowest bin.
double wt_above_
 Number above highest bin.
int n_obs_
 Total number of examples supplied.
double total_wt_
 Total sum of weights supplied.

Detailed Description

Simple object to build histogram from supplied data, with weights.

Each observation is supplied with a weight. Record total weight in each bin of the histogram.

Definition at line 16 of file mbl_wt_histogram.h.


Constructor & Destructor Documentation

mbl_wt_histogram::mbl_wt_histogram ( )

Construct with no bins.

Definition at line 13 of file mbl_wt_histogram.cxx.

mbl_wt_histogram::mbl_wt_histogram ( double  x_lo,
double  x_hi,
int  n_bins 
)

Construct with given number of bins over given range.

Definition at line 19 of file mbl_wt_histogram.cxx.


Member Function Documentation

void mbl_wt_histogram::b_read ( vsl_b_istream bfs)

Definition at line 101 of file mbl_wt_histogram.cxx.

void mbl_wt_histogram::b_write ( vsl_b_ostream bfs) const

Definition at line 89 of file mbl_wt_histogram.cxx.

void mbl_wt_histogram::clear ( )

Remove all data.

Definition at line 37 of file mbl_wt_histogram.cxx.

double mbl_wt_histogram::dx ( ) const [inline]

Bin width. Bin i is given by [bin_t0()+i*dx(),bin_t0()+(i+1)*dx()).

Definition at line 61 of file mbl_wt_histogram.h.

int mbl_wt_histogram::n_bins ( ) const [inline]

Number of bins.

Definition at line 55 of file mbl_wt_histogram.h.

int mbl_wt_histogram::n_obs ( ) const [inline]

Number of observations.

Definition at line 64 of file mbl_wt_histogram.h.

void mbl_wt_histogram::obs ( double  v,
double  wt 
)

Add given observation.

Definition at line 46 of file mbl_wt_histogram.cxx.

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

Test for equality.

Definition at line 67 of file mbl_wt_histogram.cxx.

void mbl_wt_histogram::print_summary ( vcl_ostream &  os) const

Definition at line 127 of file mbl_wt_histogram.cxx.

void mbl_wt_histogram::set_bins ( double  x_lo,
double  x_hi,
int  n_bins 
)

Define number and size of bins.

Definition at line 25 of file mbl_wt_histogram.cxx.

double mbl_wt_histogram::total_wt ( ) const [inline]

Total sum of weights supplied.

Definition at line 67 of file mbl_wt_histogram.h.

short mbl_wt_histogram::version_no ( ) const

Version number for I/O.

Definition at line 84 of file mbl_wt_histogram.cxx.

bool mbl_wt_histogram::write_probabilities ( const char *  path)

Write out probabilities (freq/wt) to a named file.

Write out histogram probabilities to a named file.

Can then be plotted by your favorite tool

Format: (bin-centre) prob (one per line)

Returns:
true if successful

Format: (bin-centre) prob (one per line)

Returns:
true if successful

Definition at line 149 of file mbl_wt_histogram.cxx.

double mbl_wt_histogram::wt_above ( ) const [inline]

Total weight above highest bin (bin_t0()+(n_bins()-1) * dx()).

Definition at line 76 of file mbl_wt_histogram.h.

double mbl_wt_histogram::wt_below ( ) const [inline]

Total weight below lowest bin (bin_t0()).

Definition at line 73 of file mbl_wt_histogram.h.

const vcl_vector<double>& mbl_wt_histogram::wt_sum ( ) const [inline]

Total weight in each bin.

Definition at line 70 of file mbl_wt_histogram.h.

double mbl_wt_histogram::xlo ( ) const [inline]

Bin width. Bin i is given by [bin_t0()+i*dx(),bin_t0()+(i+1)*dx()).

Definition at line 58 of file mbl_wt_histogram.h.


Member Data Documentation

double mbl_wt_histogram::dx_ [private]

Bin width. Bin i is given by [xlo_+i*dx_,xlo_+(i+1)*dx_).

Definition at line 22 of file mbl_wt_histogram.h.

int mbl_wt_histogram::n_obs_ [private]

Total number of examples supplied.

Definition at line 34 of file mbl_wt_histogram.h.

double mbl_wt_histogram::total_wt_ [private]

Total sum of weights supplied.

Definition at line 37 of file mbl_wt_histogram.h.

double mbl_wt_histogram::wt_above_ [private]

Number above highest bin.

Definition at line 31 of file mbl_wt_histogram.h.

double mbl_wt_histogram::wt_below_ [private]

Number below lowest bin.

Definition at line 28 of file mbl_wt_histogram.h.

vcl_vector<double> mbl_wt_histogram::wt_sum_ [private]

Total weight in each bin.

Definition at line 25 of file mbl_wt_histogram.h.

double mbl_wt_histogram::xlo_ [private]

Bin i is given by [xlo_+i*dx_,xlo_+(i+1)*dx_).

Definition at line 19 of file mbl_wt_histogram.h.


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