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

PLearn::HistogramDistribution Class Reference

#include <HistogramDistribution.h>

Inheritance diagram for PLearn::HistogramDistribution:

Inheritance graph
[legend]
Collaboration diagram for PLearn::HistogramDistribution:

Collaboration graph
[legend]
List of all members.

Public Types

typedef PDistribution inherited

Public Member Functions

 HistogramDistribution ()
 HistogramDistribution (VMat data, PP< Binner > binner_=0, PP< Smoother > smoother_=0)
 This constructor calls train as part of the construction process.

virtual void build ()
 simply calls inherited::build() then build_()

virtual void makeDeepCopyFromShallowCopy (map< const void *, void * > &copies)
 Transforms a shallow copy into a deep copy.

 PLEARN_DECLARE_OBJECT (HistogramDistribution)
 Declares name and deepCopy methods.

virtual void train ()
 trains the model

virtual void computeOutput (const Vec &input, Vec &output)
 computes the output of a trained model

virtual double log_density (const Vec &x) const
 return log of probability density log(p(x))

virtual double density (const Vec &x) const
 return probability density p(x) [ default version returns exp(log_density(x)) ]

virtual double survival_fn (const Vec &x) const
 return survival fn = P(X>x)

virtual double cdf (const Vec &x) const
 return survival fn = P(X<x)

virtual void expectation (Vec &mu) const
 return E[X]

virtual void variance (Mat &cov) const
 return Var[X]

virtual double prob_in_range (const Vec &x0, const Vec &x1) const
 return P(x0 < X < x1)

int find_bin (real x) const
 Find the bin where x belongs; -1 if x is out of range.

void calc_density_from_survival ()
 calculate bin_density from survival_values

void calc_survival_from_density ()
 calculate survival_values from bin_density


Static Public Member Functions

void calc_density_from_survival (const Vec &survival, Vec &density_, const Vec &positions)
 calculate density from survival - static, on 2 Vecs

void calc_survival_from_density (const Vec &density_, Vec &survival, const Vec &positions)
 calculate survival from density - static, on 2 Vecs


Public Attributes

Vec bin_positions
 there is one more bin position than number of bins, all the bins are supposed adjacent

Vec bin_density
 the density is supposed constant within each bin: p(x) = bin_density[i] if bin_positions[i] < x <= bin_positions[i+1]

Vec survival_values
 redundant with density is the pre-computed (optional) survival fn

PP< Binnerbinner
 this Binner is used to do binning at training time.

PP< Smoothersmoother
 this Smoother is used at training time.

bool smooth_density_instead_of_survival_fn
 whether to smooth the density or the survival function


Static Protected Member Functions

void declareOptions (OptionList &ol)
 Declares this class' options.


Private Member Functions

void build_ ()
 This does the actual building.


Member Typedef Documentation

typedef PDistribution PLearn::HistogramDistribution::inherited
 

Reimplemented from PLearn::PDistribution.

Definition at line 77 of file HistogramDistribution.h.


Constructor & Destructor Documentation

PLearn::HistogramDistribution::HistogramDistribution  ) 
 

Definition at line 47 of file HistogramDistribution.cc.

PLearn::HistogramDistribution::HistogramDistribution VMat  data,
PP< Binner binner_ = 0,
PP< Smoother smoother_ = 0
 

This constructor calls train as part of the construction process.

The computeOutput function can then be used right away.

Definition at line 49 of file HistogramDistribution.cc.

References train().


Member Function Documentation

void PLearn::HistogramDistribution::build  )  [virtual]
 

simply calls inherited::build() then build_()

Reimplemented from PLearn::PDistribution.

Definition at line 102 of file HistogramDistribution.cc.

References build_().

void PLearn::HistogramDistribution::build_  )  [private]
 

This does the actual building.

Reimplemented from PLearn::PDistribution.

Definition at line 97 of file HistogramDistribution.cc.

Referenced by build().

void PLearn::HistogramDistribution::calc_density_from_survival const Vec survival,
Vec density_,
const Vec positions
[static]
 

calculate density from survival - static, on 2 Vecs

Definition at line 321 of file HistogramDistribution.cc.

References PLearn::TVec< T >::length(), PLearn::TVec< T >::resize(), and PLearn::sum().

void PLearn::HistogramDistribution::calc_density_from_survival  ) 
 

calculate bin_density from survival_values

Definition at line 288 of file HistogramDistribution.cc.

References bin_density, bin_positions, and survival_values.

Referenced by train().

void PLearn::HistogramDistribution::calc_survival_from_density const Vec density_,
Vec survival,
const Vec positions
[static]
 

calculate survival from density - static, on 2 Vecs

Definition at line 336 of file HistogramDistribution.cc.

References PLearn::TVec< T >::length(), and PLearn::TVec< T >::resize().

void PLearn::HistogramDistribution::calc_survival_from_density  ) 
 

calculate survival_values from bin_density

Definition at line 307 of file HistogramDistribution.cc.

References bin_density, bin_positions, and survival_values.

Referenced by train().

double PLearn::HistogramDistribution::cdf const Vec x  )  const [virtual]
 

return survival fn = P(X<x)

Reimplemented from PLearn::PDistribution.

Definition at line 231 of file HistogramDistribution.cc.

References survival_fn(), and x.

Referenced by computeOutput().

void PLearn::HistogramDistribution::computeOutput const Vec input,
Vec output
[virtual]
 

computes the output of a trained model

Definition at line 173 of file HistogramDistribution.cc.

References cdf(), density(), expectation(), log_density(), PLearn::Mat, PLERROR, PLearn::TVec< T >::size(), survival_fn(), and PLearn::variance().

void PLearn::HistogramDistribution::declareOptions OptionList ol  )  [static, protected]
 

Declares this class' options.

Reimplemented from PLearn::PDistribution.

Definition at line 67 of file HistogramDistribution.cc.

References PLearn::declareOption(), and PLearn::OptionList.

double PLearn::HistogramDistribution::density const Vec x  )  const [virtual]
 

return probability density p(x) [ default version returns exp(log_density(x)) ]

Reimplemented from PLearn::PDistribution.

Definition at line 205 of file HistogramDistribution.cc.

References bin_density, find_bin(), PLERROR, and x.

Referenced by computeOutput(), and log_density().

void PLearn::HistogramDistribution::expectation Vec mu  )  const [virtual]
 

return E[X]

Reimplemented from PLearn::PDistribution.

Definition at line 236 of file HistogramDistribution.cc.

References bin_density, bin_positions, PLERROR, PLearn::TVec< T >::size(), and PLearn::sum().

Referenced by computeOutput().

int PLearn::HistogramDistribution::find_bin real  x  )  const
 

Find the bin where x belongs; -1 if x is out of range.

Definition at line 268 of file HistogramDistribution.cc.

References bin_positions, PLearn::TVec< T >::length(), and x.

Referenced by density(), and survival_fn().

double PLearn::HistogramDistribution::log_density const Vec x  )  const [virtual]
 

return log of probability density log(p(x))

Reimplemented from PLearn::PDistribution.

Definition at line 199 of file HistogramDistribution.cc.

References density(), PLearn::log(), and x.

Referenced by computeOutput().

void PLearn::HistogramDistribution::makeDeepCopyFromShallowCopy map< const void *, void * > &  copies  )  [virtual]
 

Transforms a shallow copy into a deep copy.

Reimplemented from PLearn::PDistribution.

Definition at line 188 of file HistogramDistribution.cc.

References bin_density, bin_positions, binner, PLearn::deepCopyField(), smoother, and survival_values.

PLearn::HistogramDistribution::PLEARN_DECLARE_OBJECT HistogramDistribution   ) 
 

Declares name and deepCopy methods.

double PLearn::HistogramDistribution::prob_in_range const Vec x0,
const Vec x1
const [virtual]
 

return P(x0 < X < x1)

Definition at line 262 of file HistogramDistribution.cc.

References survival_fn().

double PLearn::HistogramDistribution::survival_fn const Vec x  )  const [virtual]
 

return survival fn = P(X>x)

Reimplemented from PLearn::PDistribution.

Definition at line 213 of file HistogramDistribution.cc.

References bin_positions, find_bin(), PLERROR, survival_values, and x.

Referenced by cdf(), computeOutput(), and prob_in_range().

void PLearn::HistogramDistribution::train  )  [virtual]
 

trains the model

Reimplemented from PLearn::PDistribution.

Definition at line 108 of file HistogramDistribution.cc.

References bin_density, bin_positions, binner, calc_density_from_survival(), calc_survival_from_density(), PLearn::VMat::getColumn(), PLearn::PLearner::inputsize(), PLearn::TVec< T >::length(), PLearn::VMat::length(), PLERROR, PLearn::TVec< T >::resize(), smooth_density_instead_of_survival_fn, smoother, survival_values, PLearn::PLearner::targetsize(), PLearn::Vec, and PLearn::VMat::width().

Referenced by HistogramDistribution().

void PLearn::HistogramDistribution::variance Mat cov  )  const [virtual]
 

return Var[X]

Reimplemented from PLearn::PDistribution.

Definition at line 247 of file HistogramDistribution.cc.

References PLearn::abs(), bin_density, bin_positions, PLERROR, PLearn::TVec< T >::size(), PLearn::TMat< T >::size(), and PLearn::sum().


Member Data Documentation

Vec PLearn::HistogramDistribution::bin_density
 

the density is supposed constant within each bin: p(x) = bin_density[i] if bin_positions[i] < x <= bin_positions[i+1]

Definition at line 63 of file HistogramDistribution.h.

Referenced by calc_density_from_survival(), calc_survival_from_density(), density(), expectation(), makeDeepCopyFromShallowCopy(), train(), and variance().

Vec PLearn::HistogramDistribution::bin_positions
 

there is one more bin position than number of bins, all the bins are supposed adjacent

Definition at line 59 of file HistogramDistribution.h.

Referenced by calc_density_from_survival(), calc_survival_from_density(), expectation(), find_bin(), makeDeepCopyFromShallowCopy(), survival_fn(), train(), and variance().

PP<Binner> PLearn::HistogramDistribution::binner
 

this Binner is used to do binning at training time.

Definition at line 69 of file HistogramDistribution.h.

Referenced by makeDeepCopyFromShallowCopy(), and train().

bool PLearn::HistogramDistribution::smooth_density_instead_of_survival_fn
 

whether to smooth the density or the survival function

Definition at line 75 of file HistogramDistribution.h.

Referenced by train().

PP<Smoother> PLearn::HistogramDistribution::smoother
 

this Smoother is used at training time.

Definition at line 72 of file HistogramDistribution.h.

Referenced by makeDeepCopyFromShallowCopy(), and train().

Vec PLearn::HistogramDistribution::survival_values
 

redundant with density is the pre-computed (optional) survival fn

Definition at line 66 of file HistogramDistribution.h.

Referenced by calc_density_from_survival(), calc_survival_from_density(), makeDeepCopyFromShallowCopy(), survival_fn(), and train().


The documentation for this class was generated from the following files:
Generated on Tue Aug 17 16:27:16 2004 for PLearn by doxygen 1.3.7