KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
kjb::Learned_discrete_prior Class Reference

This class creates a histogram of a list of points and stores the number of bins in num_bins, the maximum and minimum values allowed in histo_max and histo_min, respectively, and the count of the number of points in each bin in histo_bins, which is a Vector of size num_bins. More...

#include <learned_discrete_prior.h>

Inheritance diagram for kjb::Learned_discrete_prior:
kjb::Readable kjb::Writeable

Public Member Functions

 Learned_discrete_prior (int numBins, double max, double min, const char *fname, int softBin=1)
 Constructor. More...
 
 Learned_discrete_prior ()
 
 Learned_discrete_prior (const Learned_discrete_prior &dp)
 Copy constructor. More...
 
 Learned_discrete_prior (const char *fname) throw (kjb::Illegal_argument, kjb::IO_error)
 Constructs a parametric_parapiped from an input file. More...
 
 Learned_discrete_prior (std::istream &in) throw (kjb::Illegal_argument, kjb::IO_error)
 Constructs a parametric_parapiped from an input stream. More...
 
 ~Learned_discrete_prior ()
 Destructor. More...
 
Learned_discrete_prioroperator= (const Learned_discrete_prior &dp)
 Assignment operator. More...
 
virtual void read (std::istream &in) throw (kjb::Illegal_argument, kjb::IO_error)
 Reads this parametric_parapiped from an input stream. More...
 
virtual void read (const char *fname) throw (kjb::IO_error, kjb::Illegal_argument)
 Reads this parametric_parapiped from a file. More...
 
virtual void write (std::ostream &out) const throw (kjb::IO_error)
 Writes this parametric_parapiped to a file. More...
 
virtual void write (const char *fname) const throw (kjb::IO_error)
 Writes this parametric_parapiped to an output stream. More...
 
int get_num_bins () const
 Returns the number of bins. More...
 
double get_histo_max () const
 Returns the maximum value of the histogram. More...
 
double get_histo_min () const
 Returns the minimum value of the histogram. More...
 
const Vectorget_histo_bins () const
 Returns the Vector containing the count of points in each bin. More...
 
int plot_histogram (const char *name=NULL) const
 Creates a plot of the histogram and saves it in ps format in a file with the provided name or plot.ps if no name is provided. More...
 
double evaluate_prior (double value) const
 
- Public Member Functions inherited from kjb::Readable
virtual ~Readable ()
 Deletes this Readable. More...
 
- Public Member Functions inherited from kjb::Writeable
virtual ~Writeable ()
 Deletes this Writeable. More...
 

Static Public Member Functions

static void find_min_max (double &hmax, double &hmin, const char *fname)
 
- Static Public Member Functions inherited from kjb::Readable
static const char * read_field_value (std::istream &in, const char *field_name, char *field_buf, size_t buf_len, char separator=':')
 Reads a line off in into a buffer and returns a pointer to the field value in the buffer. More...
 
static const char * read_field_value (std::istream &in, const char *field_name, char separator=':')
 Reads a line off in into an internal buffer and returns a pointer to the field value in the buffer. More...
 

Protected Member Functions

void find_bin (double &bin, double element, int numBins, double min, double max) const
 Determines which bin in the histogram the given element should be put in. More...
 

Detailed Description

This class creates a histogram of a list of points and stores the number of bins in num_bins, the maximum and minimum values allowed in histo_max and histo_min, respectively, and the count of the number of points in each bin in histo_bins, which is a Vector of size num_bins.

Constructor & Destructor Documentation

Learned_discrete_prior::Learned_discrete_prior ( int  numBins,
double  max,
double  min,
const char *  fname,
int  softBin = 1 
)

Constructor.

Parameters
numBinsNumber of bins in the histogram.
maxDouble representing the maximum value of the histogram.
minDouble representing the minimum value of the histogram.
fnameInput file to read the data to build the histogram from.
softBin1 if want to create histogram using soft-binning (default), 0 if not.
kjb::Learned_discrete_prior::Learned_discrete_prior ( )
inline
Learned_discrete_prior::Learned_discrete_prior ( const Learned_discrete_prior dp)

Copy constructor.

Parameters
dpthe Learned_discrete_prior object to copy into this one.
kjb::Learned_discrete_prior::Learned_discrete_prior ( const char *  fname)
throw (kjb::Illegal_argument,
kjb::IO_error
)
inline

Constructs a parametric_parapiped from an input file.

kjb::Learned_discrete_prior::Learned_discrete_prior ( std::istream &  in)
throw (kjb::Illegal_argument,
kjb::IO_error
)
inline

Constructs a parametric_parapiped from an input stream.

Learned_discrete_prior::~Learned_discrete_prior ( )

Destructor.

Frees all space allocated by this object.

Member Function Documentation

double kjb::Learned_discrete_prior::evaluate_prior ( double  value) const
inline
void Learned_discrete_prior::find_bin ( double &  bin,
double  element,
int  numBins,
double  min,
double  max 
) const
protected

Determines which bin in the histogram the given element should be put in.

Parameters
binDouble to store the number of the bin to add the element to.
elementThe element to be added to the histogram.
numBinsThe number of bins in the histogram.
minThe minimum value that can be added to the histogram.
maxThe maximum value that can be added to the histogram.
void Learned_discrete_prior::find_min_max ( double &  hmax,
double &  hmin,
const char *  fname 
)
static
const Vector & Learned_discrete_prior::get_histo_bins ( ) const

Returns the Vector containing the count of points in each bin.

Returns
The Vector containing the count of points in each bin.
double Learned_discrete_prior::get_histo_max ( ) const

Returns the maximum value of the histogram.

Returns
The maximum value of the histogram.
double Learned_discrete_prior::get_histo_min ( ) const

Returns the minimum value of the histogram.

Returns
The minimum value of the histogram.
int Learned_discrete_prior::get_num_bins ( ) const

Returns the number of bins.

Returns
The number of bins in the histogram.
Learned_discrete_prior & Learned_discrete_prior::operator= ( const Learned_discrete_prior dp)

Assignment operator.

Performs a deep copy of the histogram bins.

Parameters
dpLearned_discrete_prior to copy into this one.
Returns
A reference to this Learned_discrete_prior.
int Learned_discrete_prior::plot_histogram ( const char *  name = NULL) const

Creates a plot of the histogram and saves it in ps format in a file with the provided name or plot.ps if no name is provided.

Parameters
nameThe name of the ps file the histogram plot will be saved to. If NULL, the plot will be saved to a file called plot.ps
Returns
NO_ERROR on success and ERROR on failure.
void Learned_discrete_prior::read ( std::istream &  in)
throw (kjb::Illegal_argument,
kjb::IO_error
)
virtual

Reads this parametric_parapiped from an input stream.

Implements kjb::Readable.

virtual void kjb::Learned_discrete_prior::read ( const char *  fname)
throw (kjb::IO_error,
kjb::Illegal_argument
)
inlinevirtual

Reads this parametric_parapiped from a file.

Reimplemented from kjb::Readable.

void Learned_discrete_prior::write ( std::ostream &  out) const
throw (kjb::IO_error
)
virtual

Writes this parametric_parapiped to a file.

Writes this learn_discrete_prior to a file.

Implements kjb::Writeable.

virtual void kjb::Learned_discrete_prior::write ( const char *  fname) const
throw (kjb::IO_error
)
inlinevirtual

Writes this parametric_parapiped to an output stream.

Reimplemented from kjb::Writeable.


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