Simple object to build histogram from supplied data. More...
#include <mbl_histogram.h>
Public Member Functions | |
mbl_histogram () | |
Construct with no bins. | |
mbl_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) |
Add given observation. | |
int | n_bins () const |
Number of bins. | |
const vcl_vector< double > & | bins () const |
Position of limits of each bin. | |
int | n_obs () const |
Number of observations. | |
const vcl_vector< int > & | frequency () const |
Number in each bin. | |
int | n_below () const |
Number below lowest bin. | |
int | n_above () const |
Number above highest bin. | |
bool | write_probabilities (const char *path) |
Write out probabilities (freq/n_obs) to a named file. | |
bool | write_cdf (const char *path) |
Write out cumulative probability distribution 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_histogram &s) const |
Test for equality. | |
Private Attributes | |
vcl_vector< double > | bins_ |
Position of limits of each bin. | |
vcl_vector< int > | freq_ |
Number in each bin. | |
int | n_below_ |
Number below lowest bin. | |
int | n_above_ |
Number above highest bin. | |
int | n_obs_ |
Total number of examples supplied. |
Simple object to build histogram from supplied data.
Assumes all 1D data can be cast to doubles One could perhaps re-write this, templated by object type, if really necessary.
Definition at line 16 of file mbl_histogram.h.
mbl_histogram::mbl_histogram | ( | ) |
Construct with no bins.
Definition at line 13 of file mbl_histogram.cxx.
mbl_histogram::mbl_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_histogram.cxx.
void mbl_histogram::b_read | ( | vsl_b_istream & | bfs | ) |
Definition at line 106 of file mbl_histogram.cxx.
void mbl_histogram::b_write | ( | vsl_b_ostream & | bfs | ) | const |
Definition at line 96 of file mbl_histogram.cxx.
const vcl_vector<double>& mbl_histogram::bins | ( | ) | const [inline] |
Position of limits of each bin.
Bin i is [bins_[i],bins_[i+1])
Definition at line 54 of file mbl_histogram.h.
void mbl_histogram::clear | ( | ) |
Remove all data.
Definition at line 38 of file mbl_histogram.cxx.
const vcl_vector<int>& mbl_histogram::frequency | ( | ) | const [inline] |
Number in each bin.
Definition at line 60 of file mbl_histogram.h.
int mbl_histogram::n_above | ( | ) | const [inline] |
Number above highest bin.
Definition at line 66 of file mbl_histogram.h.
int mbl_histogram::n_below | ( | ) | const [inline] |
Number below lowest bin.
Definition at line 63 of file mbl_histogram.h.
int mbl_histogram::n_bins | ( | ) | const [inline] |
Number of bins.
Definition at line 50 of file mbl_histogram.h.
int mbl_histogram::n_obs | ( | ) | const [inline] |
Number of observations.
Definition at line 57 of file mbl_histogram.h.
void mbl_histogram::obs | ( | double | v | ) |
Add given observation.
Definition at line 46 of file mbl_histogram.cxx.
bool mbl_histogram::operator== | ( | const mbl_histogram & | s | ) | const |
Test for equality.
Definition at line 74 of file mbl_histogram.cxx.
void mbl_histogram::print_summary | ( | vcl_ostream & | os | ) | const |
Definition at line 130 of file mbl_histogram.cxx.
void mbl_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_histogram.cxx.
short mbl_histogram::version_no | ( | ) | const |
Version number for I/O.
Definition at line 91 of file mbl_histogram.cxx.
bool mbl_histogram::write_cdf | ( | const char * | path | ) |
Write out cumulative probability distribution to a named file.
Format: (bin-centre) sum_prob (one per line)
Definition at line 171 of file mbl_histogram.cxx.
bool mbl_histogram::write_probabilities | ( | const char * | path | ) |
Write out probabilities (freq/n_obs) 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)
Format: (bin-centre) prob (one per line)
Definition at line 152 of file mbl_histogram.cxx.
vcl_vector<double> mbl_histogram::bins_ [private] |
Position of limits of each bin.
Bin i is [bins_[i],bins_[i+1])
Definition at line 20 of file mbl_histogram.h.
vcl_vector<int> mbl_histogram::freq_ [private] |
Number in each bin.
Definition at line 23 of file mbl_histogram.h.
int mbl_histogram::n_above_ [private] |
Number above highest bin.
Definition at line 29 of file mbl_histogram.h.
int mbl_histogram::n_below_ [private] |
Number below lowest bin.
Definition at line 26 of file mbl_histogram.h.
int mbl_histogram::n_obs_ [private] |
Total number of examples supplied.
Definition at line 32 of file mbl_histogram.h.