#include <HistogramDistribution.h>
Inheritance diagram for PLearn::HistogramDistribution:
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< Binner > | binner |
this Binner is used to do binning at training time. | |
PP< Smoother > | smoother |
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. |
|
Reimplemented from PLearn::PDistribution. Definition at line 77 of file HistogramDistribution.h. |
|
Definition at line 47 of file HistogramDistribution.cc. |
|
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(). |
|
simply calls inherited::build() then build_()
Reimplemented from PLearn::PDistribution. Definition at line 102 of file HistogramDistribution.cc. References build_(). |
|
This does the actual building.
Reimplemented from PLearn::PDistribution. Definition at line 97 of file HistogramDistribution.cc. Referenced by build(). |
|
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(). |
|
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(). |
|
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(). |
|
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(). |
|
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(). |
|
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(). |
|
Declares this class' options.
Reimplemented from PLearn::PDistribution. Definition at line 67 of file HistogramDistribution.cc. References PLearn::declareOption(), and PLearn::OptionList. |
|
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(). |
|
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(). |
|
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(). |
|
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(). |
|
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. |
|
Declares name and deepCopy methods.
|
|
return P(x0 < X < x1)
Definition at line 262 of file HistogramDistribution.cc. References survival_fn(). |
|
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(). |
|
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(). |
|
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(). |
|
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(). |
|
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(). |
|
this Binner is used to do binning at training time.
Definition at line 69 of file HistogramDistribution.h. Referenced by makeDeepCopyFromShallowCopy(), and train(). |
|
whether to smooth the density or the survival function
Definition at line 75 of file HistogramDistribution.h. Referenced by train(). |
|
this Smoother is used at training time.
Definition at line 72 of file HistogramDistribution.h. Referenced by makeDeepCopyFromShallowCopy(), and train(). |
|
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(). |