Base class for Univariate Probability Density Function classes. More...
#include <pdf1d_pdf.h>
Public Member Functions | |
pdf1d_pdf () | |
Dflt ctor. | |
virtual | ~pdf1d_pdf () |
Destructor. | |
double | mean () const |
Mean of distribution. | |
double | variance () const |
Variance of each dimension. | |
virtual int | n_peaks () const |
Number of peaks of distribution. | |
virtual double | peak (int) const |
Position of the i'th peak. | |
virtual double | log_p (double x) const =0 |
Log of probability density at x. | |
virtual double | operator() (double x) const |
Probability density at x. | |
virtual double | cdf (double x) const |
Cumulative Probability (P(x'<x) for x' drawn from the distribution. | |
virtual bool | cdf_is_analytic () const |
Return true if cdf() uses an analytic implementation. | |
virtual double | inverse_cdf (double P) const |
The inverse cdf. | |
virtual double | gradient (double x, double &p) const =0 |
Gradient and value of PDF at x. | |
virtual pdf1d_sampler * | new_sampler () const =0 |
Create a sampler object on the heap. | |
virtual double | log_prob_thresh (double pass_proportion) const |
Compute threshold for PDF to pass a given proportion. | |
virtual double | nearest_plausible (double x, double log_p_min) const =0 |
Compute nearest point to x which has a density above a threshold. | |
virtual bool | is_valid_pdf () const |
Return true if the object represents a valid PDF. | |
void | get_samples (vnl_vector< double > &x) const |
Fill x with samples drawn from distribution. | |
short | version_no () const |
Version number for I/O. | |
virtual vcl_string | is_a () const |
Name of the class. | |
virtual bool | is_class (vcl_string const &s) const |
Does the name of the class match the argument?. | |
virtual pdf1d_pdf * | clone () const =0 |
Create a copy on the heap and return base class pointer. | |
virtual void | print_summary (vcl_ostream &os) const =0 |
Print class to os. | |
virtual void | b_write (vsl_b_ostream &bfs) const =0 |
Save class to binary file stream. | |
virtual void | b_read (vsl_b_istream &bfs)=0 |
Load class from binary file stream. | |
bool | write_plot_file (const vcl_string &plot_file, double min_x, double max_x, int n) const |
Write values (x,p(x)) to text file suitable for plotting. | |
Protected Member Functions | |
void | set_mean (double m) |
void | set_variance (double v) |
Private Attributes | |
double | mean_ |
double | var_ |
Base class for Univariate Probability Density Function classes.
Functions are available to test the plausibility of a vector or set of parameters, to modify a set of parameters so it is plausible and to choose a threshold of plausibility. Also, for cases where the distributions of parameters are multi-modal, the number and centres of each peak can be recorded. This is particularly useful for non-linear and mixture model representations of the parameter distributions.
Definition at line 26 of file pdf1d_pdf.h.
pdf1d_pdf::pdf1d_pdf | ( | ) |
Dflt ctor.
Definition at line 24 of file pdf1d_pdf.cxx.
pdf1d_pdf::~pdf1d_pdf | ( | ) | [virtual] |
Destructor.
Definition at line 31 of file pdf1d_pdf.cxx.
void pdf1d_pdf::b_read | ( | vsl_b_istream & | bfs | ) | [pure virtual] |
Load class from binary file stream.
Implemented in pdf1d_mixture, pdf1d_flat, pdf1d_gaussian, pdf1d_exponential, pdf1d_kernel_pdf, pdf1d_weighted_kernel_pdf, pdf1d_epanech_kernel_pdf, and pdf1d_gaussian_kernel_pdf.
Definition at line 211 of file pdf1d_pdf.cxx.
void pdf1d_pdf::b_write | ( | vsl_b_ostream & | bfs | ) | const [pure virtual] |
Save class to binary file stream.
Implemented in pdf1d_mixture, pdf1d_flat, pdf1d_gaussian, pdf1d_exponential, pdf1d_kernel_pdf, pdf1d_weighted_kernel_pdf, pdf1d_epanech_kernel_pdf, and pdf1d_gaussian_kernel_pdf.
Definition at line 201 of file pdf1d_pdf.cxx.
double pdf1d_pdf::cdf | ( | double | x0 | ) | const [virtual] |
Cumulative Probability (P(x'<x) for x' drawn from the distribution.
Cumulative Probability (P(x'<x) for x' drawn from the distribution).
By default this can be calculated by drawing random samples from the distribution and computing the number less than x.
Reimplemented in pdf1d_flat, pdf1d_gaussian, pdf1d_exponential, pdf1d_mixture, pdf1d_epanech_kernel_pdf, pdf1d_gaussian_kernel_pdf, and pdf1d_weighted_epanech_kernel_pdf.
Definition at line 45 of file pdf1d_pdf.cxx.
bool pdf1d_pdf::cdf_is_analytic | ( | ) | const [virtual] |
Return true if cdf() uses an analytic implementation.
Default is false, as the base implementation is to draw samples from the distribution randomly to estimate cdf(x)
Reimplemented in pdf1d_flat, pdf1d_gaussian, pdf1d_exponential, pdf1d_mixture, pdf1d_epanech_kernel_pdf, pdf1d_gaussian_kernel_pdf, and pdf1d_weighted_epanech_kernel_pdf.
Definition at line 62 of file pdf1d_pdf.cxx.
virtual pdf1d_pdf* pdf1d_pdf::clone | ( | ) | const [pure virtual] |
Create a copy on the heap and return base class pointer.
Implemented in pdf1d_mixture, pdf1d_flat, pdf1d_gaussian, pdf1d_exponential, pdf1d_epanech_kernel_pdf, pdf1d_gaussian_kernel_pdf, and pdf1d_weighted_epanech_kernel_pdf.
void pdf1d_pdf::get_samples | ( | vnl_vector< double > & | x | ) | const |
Fill x with samples drawn from distribution.
Utility function. This calls new_sampler() to do the work, then deletes the sampler again. If you intend calling this repeatedly, create a sampler yourself.
Definition at line 132 of file pdf1d_pdf.cxx.
virtual double pdf1d_pdf::gradient | ( | double | x, |
double & | p | ||
) | const [pure virtual] |
Gradient and value of PDF at x.
Computes gradient of PDF at x, and returns the prob at x in p
Implemented in pdf1d_flat, pdf1d_gaussian, pdf1d_exponential, pdf1d_mixture, pdf1d_epanech_kernel_pdf, pdf1d_gaussian_kernel_pdf, and pdf1d_weighted_epanech_kernel_pdf.
double pdf1d_pdf::inverse_cdf | ( | double | P | ) | const [virtual] |
The inverse cdf.
The inverse cumulative distribution function.
The value of x: P(x'<x) = P for x' drawn from distribution pdf. The default version of this algorithm uses sampling if !cdf_is_analytic(), and Newton-Raphson root finding otherwise.
The value of x: P(x'<x) = P for x' drawn from distribution pdf.
Reimplemented in pdf1d_kernel_pdf.
Definition at line 288 of file pdf1d_pdf.cxx.
vcl_string pdf1d_pdf::is_a | ( | ) | const [virtual] |
Name of the class.
Reimplemented in pdf1d_mixture, pdf1d_flat, pdf1d_gaussian, pdf1d_exponential, pdf1d_kernel_pdf, pdf1d_weighted_kernel_pdf, pdf1d_epanech_kernel_pdf, pdf1d_gaussian_kernel_pdf, and pdf1d_weighted_epanech_kernel_pdf.
Definition at line 176 of file pdf1d_pdf.cxx.
bool pdf1d_pdf::is_class | ( | vcl_string const & | s | ) | const [virtual] |
Does the name of the class match the argument?.
Reimplemented in pdf1d_mixture, pdf1d_flat, pdf1d_gaussian, pdf1d_exponential, pdf1d_kernel_pdf, pdf1d_weighted_kernel_pdf, pdf1d_epanech_kernel_pdf, pdf1d_gaussian_kernel_pdf, and pdf1d_weighted_epanech_kernel_pdf.
Definition at line 184 of file pdf1d_pdf.cxx.
bool pdf1d_pdf::is_valid_pdf | ( | ) | const [virtual] |
Return true if the object represents a valid PDF.
This will return false, if n_dims() is 0, for example just ofter default construction.
Reimplemented in pdf1d_mixture.
Definition at line 126 of file pdf1d_pdf.cxx.
virtual double pdf1d_pdf::log_p | ( | double | x | ) | const [pure virtual] |
Log of probability density at x.
Implemented in pdf1d_flat, pdf1d_gaussian, pdf1d_exponential, pdf1d_mixture, pdf1d_epanech_kernel_pdf, pdf1d_gaussian_kernel_pdf, and pdf1d_weighted_epanech_kernel_pdf.
double pdf1d_pdf::log_prob_thresh | ( | double | pass_proportion | ) | const [virtual] |
Compute threshold for PDF to pass a given proportion.
Reimplemented in pdf1d_flat, pdf1d_gaussian, and pdf1d_exponential.
Definition at line 68 of file pdf1d_pdf.cxx.
double pdf1d_pdf::mean | ( | ) | const [inline] |
Mean of distribution.
Definition at line 42 of file pdf1d_pdf.h.
virtual int pdf1d_pdf::n_peaks | ( | ) | const [inline, virtual] |
Number of peaks of distribution.
Definition at line 48 of file pdf1d_pdf.h.
virtual double pdf1d_pdf::nearest_plausible | ( | double | x, |
double | log_p_min | ||
) | const [pure virtual] |
Compute nearest point to x which has a density above a threshold.
If log_p(x)>log_p_min then x returned unchanged. Otherwise move (typically up the gradient) until log_p(x)>=log_p_min.
Implemented in pdf1d_flat, pdf1d_gaussian, pdf1d_exponential, pdf1d_mixture, pdf1d_epanech_kernel_pdf, pdf1d_gaussian_kernel_pdf, and pdf1d_weighted_epanech_kernel_pdf.
virtual pdf1d_sampler* pdf1d_pdf::new_sampler | ( | ) | const [pure virtual] |
Create a sampler object on the heap.
Caller is responsible for deletion.
Implemented in pdf1d_mixture, pdf1d_flat, pdf1d_gaussian, pdf1d_exponential, pdf1d_epanech_kernel_pdf, pdf1d_gaussian_kernel_pdf, and pdf1d_weighted_epanech_kernel_pdf.
double pdf1d_pdf::operator() | ( | double | x | ) | const [virtual] |
Probability density at x.
Reimplemented in pdf1d_flat, pdf1d_exponential, pdf1d_mixture, pdf1d_epanech_kernel_pdf, pdf1d_gaussian_kernel_pdf, and pdf1d_weighted_epanech_kernel_pdf.
Definition at line 37 of file pdf1d_pdf.cxx.
virtual double pdf1d_pdf::peak | ( | int | ) | const [inline, virtual] |
Position of the i'th peak.
Definition at line 51 of file pdf1d_pdf.h.
void pdf1d_pdf::print_summary | ( | vcl_ostream & | os | ) | const [pure virtual] |
Print class to os.
Implemented in pdf1d_mixture, pdf1d_flat, pdf1d_gaussian, pdf1d_exponential, pdf1d_kernel_pdf, pdf1d_weighted_kernel_pdf, pdf1d_epanech_kernel_pdf, and pdf1d_gaussian_kernel_pdf.
Definition at line 192 of file pdf1d_pdf.cxx.
void pdf1d_pdf::set_mean | ( | double | m | ) | [inline, protected] |
Reimplemented in pdf1d_gaussian.
Definition at line 31 of file pdf1d_pdf.h.
void pdf1d_pdf::set_variance | ( | double | v | ) | [inline, protected] |
Definition at line 32 of file pdf1d_pdf.h.
double pdf1d_pdf::variance | ( | ) | const [inline] |
Variance of each dimension.
Definition at line 45 of file pdf1d_pdf.h.
short pdf1d_pdf::version_no | ( | ) | const |
Version number for I/O.
Reimplemented in pdf1d_mixture, pdf1d_flat, pdf1d_gaussian, pdf1d_exponential, pdf1d_kernel_pdf, pdf1d_weighted_kernel_pdf, pdf1d_epanech_kernel_pdf, pdf1d_gaussian_kernel_pdf, and pdf1d_weighted_epanech_kernel_pdf.
Definition at line 162 of file pdf1d_pdf.cxx.
bool pdf1d_pdf::write_plot_file | ( | const vcl_string & | plot_file, |
double | min_x, | ||
double | max_x, | ||
int | n | ||
) | const |
Write values (x,p(x)) to text file suitable for plotting.
Evaluate pdf at n points in range [min_x,max_x] and write a text file, each line of which is {x p(x)}, suitable for plotting with many graph packages
Definition at line 142 of file pdf1d_pdf.cxx.
double pdf1d_pdf::mean_ [private] |
Definition at line 28 of file pdf1d_pdf.h.
double pdf1d_pdf::var_ [private] |
Definition at line 29 of file pdf1d_pdf.h.