Represents a mixture model (a set of individual pdfs + weights). More...
#include <pdf1d_mixture.h>

Public Member Functions | |
| pdf1d_mixture () | |
| Dflt ctor. | |
| pdf1d_mixture (const pdf1d_mixture &) | |
| Copy ctor. | |
| pdf1d_mixture & | operator= (const pdf1d_mixture &) |
| Copy operator. | |
| virtual | ~pdf1d_mixture () |
| Destructor. | |
| virtual double | operator() (double x) const |
| Probability density at x. | |
| virtual double | log_p (double x) const |
| Log of 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 | gradient (double x, double &p) const |
| Gradient of PDF at x. | |
| virtual double | nearest_plausible (double x, double log_p_min) const |
| Not Yet Implemented. | |
| void | init (const pdf1d_pdf &comp_type, int n) |
| Initialise to use n components of type comp_type. | |
| virtual pdf1d_sampler * | new_sampler () const |
| Return instance object for this PDF. | |
| unsigned | n_components () const |
| Number of components in mixture. | |
| double | weight (unsigned i) const |
| Get ith weight. | |
| const vcl_vector< double > & | weights () const |
| Array of weights. | |
| vcl_vector< double > & | weights () |
| Array of weights. | |
| unsigned | nearest_comp (double x) const |
| Return index of component nearest to x. | |
| void | add_component (const pdf1d_pdf &comp) |
| Add a component to current model. | |
| void | clear () |
| Remove all components cleanly. | |
| const pdf1d_pdf & | component (unsigned i) const |
| Get ith component. | |
| vcl_vector< pdf1d_pdf * > & | components () |
| Access to components - for use by builders. | |
| const vcl_vector< pdf1d_pdf * > & | components () const |
| Access to components - for use by builders. | |
| void | set_mean_and_variance (double m, double v) |
| Set the whole pdf mean and variance values. | |
| virtual bool | is_valid_pdf () const |
| Return true if the object represents a valid PDF. | |
| 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 |
| Create a copy on the heap and return base class pointer. | |
| virtual void | print_summary (vcl_ostream &os) const |
| Print class to os. | |
| virtual void | b_write (vsl_b_ostream &bfs) const |
| Save class to binary file stream. | |
| virtual void | b_read (vsl_b_istream &bfs) |
| Load class from binary file stream. | |
| 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 | inverse_cdf (double P) const |
| The inverse cdf. | |
| virtual double | log_prob_thresh (double pass_proportion) const |
| Compute threshold for PDF to pass a given proportion. | |
| void | get_samples (vnl_vector< double > &x) const |
| Fill x with samples drawn from distribution. | |
| 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 Member Functions | |
| void | init () |
| void | delete_stuff () |
Private Attributes | |
| vcl_vector< pdf1d_pdf * > | component_ |
| vcl_vector< double > | weight_ |
Represents a mixture model (a set of individual pdfs + weights).
Definition at line 18 of file pdf1d_mixture.h.
| pdf1d_mixture::pdf1d_mixture | ( | ) |
Dflt ctor.
Definition at line 26 of file pdf1d_mixture.cxx.
| pdf1d_mixture::pdf1d_mixture | ( | const pdf1d_mixture & | m | ) |
Copy ctor.
Definition at line 31 of file pdf1d_mixture.cxx.
| pdf1d_mixture::~pdf1d_mixture | ( | ) | [virtual] |
Destructor.
Definition at line 68 of file pdf1d_mixture.cxx.
| void pdf1d_mixture::add_component | ( | const pdf1d_pdf & | comp | ) |
Add a component to current model.
Clone taken of comp
Definition at line 98 of file pdf1d_mixture.cxx.
| void pdf1d_mixture::b_read | ( | vsl_b_istream & | bfs | ) | [virtual] |
Load class from binary file stream.
Implements pdf1d_pdf.
Definition at line 212 of file pdf1d_mixture.cxx.
| void pdf1d_mixture::b_write | ( | vsl_b_ostream & | bfs | ) | const [virtual] |
Save class to binary file stream.
Implements pdf1d_pdf.
Definition at line 201 of file pdf1d_mixture.cxx.
| double pdf1d_mixture::cdf | ( | double | x | ) | const [virtual] |
Cumulative Probability (P(x'<x) for x' drawn from the distribution).
Reimplemented from pdf1d_pdf.
Definition at line 283 of file pdf1d_mixture.cxx.
| bool pdf1d_mixture::cdf_is_analytic | ( | ) | const [virtual] |
Return true if cdf() uses an analytic implementation.
Reimplemented from pdf1d_pdf.
Definition at line 295 of file pdf1d_mixture.cxx.
| void pdf1d_mixture::clear | ( | ) |
Remove all components cleanly.
Definition at line 120 of file pdf1d_mixture.cxx.
| pdf1d_pdf * pdf1d_mixture::clone | ( | ) | const [virtual] |
Create a copy on the heap and return base class pointer.
Implements pdf1d_pdf.
Definition at line 178 of file pdf1d_mixture.cxx.
| const pdf1d_pdf& pdf1d_mixture::component | ( | unsigned | i | ) | const [inline] |
Get ith component.
Definition at line 96 of file pdf1d_mixture.h.
| vcl_vector<pdf1d_pdf*>& pdf1d_mixture::components | ( | ) | [inline] |
Access to components - for use by builders.
Care must be taken to ensure consistency when modifying Use component(i) where possible
Definition at line 101 of file pdf1d_mixture.h.
| const vcl_vector<pdf1d_pdf*>& pdf1d_mixture::components | ( | ) | const [inline] |
Access to components - for use by builders.
Use component(i) where possible
Definition at line 105 of file pdf1d_mixture.h.
| void pdf1d_mixture::delete_stuff | ( | ) | [private] |
Definition at line 59 of file pdf1d_mixture.cxx.
| void pdf1d_pdf::get_samples | ( | vnl_vector< double > & | x | ) | const [inherited] |
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.
| double pdf1d_mixture::gradient | ( | double | x, |
| double & | p | ||
| ) | const [virtual] |
| void pdf1d_mixture::init | ( | ) | [private] |
Definition at line 22 of file pdf1d_mixture.cxx.
| void pdf1d_mixture::init | ( | const pdf1d_pdf & | comp_type, |
| int | n | ||
| ) |
Initialise to use n components of type comp_type.
Clones taken by comp_type
Definition at line 84 of file pdf1d_mixture.cxx.
| double pdf1d_pdf::inverse_cdf | ( | double | P | ) | const [virtual, inherited] |
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_mixture::is_a | ( | ) | const [virtual] |
| bool pdf1d_mixture::is_class | ( | vcl_string const & | s | ) | const [virtual] |
Does the name of the class match the argument?.
Reimplemented from pdf1d_pdf.
Definition at line 164 of file pdf1d_mixture.cxx.
| bool pdf1d_mixture::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 from pdf1d_pdf.
Definition at line 130 of file pdf1d_mixture.cxx.
| double pdf1d_mixture::log_p | ( | double | x | ) | const [virtual] |
Log of probability density at x.
Implements pdf1d_pdf.
Definition at line 256 of file pdf1d_mixture.cxx.
| double pdf1d_pdf::log_prob_thresh | ( | double | pass_proportion | ) | const [virtual, inherited] |
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, inherited] |
Mean of distribution.
Definition at line 42 of file pdf1d_pdf.h.
| unsigned pdf1d_mixture::n_components | ( | ) | const [inline] |
Number of components in mixture.
Definition at line 71 of file pdf1d_mixture.h.
| virtual int pdf1d_pdf::n_peaks | ( | ) | const [inline, virtual, inherited] |
Number of peaks of distribution.
Definition at line 48 of file pdf1d_pdf.h.
| unsigned pdf1d_mixture::nearest_comp | ( | double | x | ) | const |
Return index of component nearest to x.
Definition at line 323 of file pdf1d_mixture.cxx.
| double pdf1d_mixture::nearest_plausible | ( | double | x, |
| double | log_p_min | ||
| ) | const [virtual] |
Not Yet Implemented.
Compute nearest point to x which has a density above a threshold.
Compute nearest point to x which has a density above a threshold If log_p(x)>log_p_min then x unchanged. Otherwise x is moved (typically up the gradient) until log_p(x)>=log_p_min.
| x | This may be modified to the nearest plausible position. |
| log_p_min | lower threshold for log_p(x) |
If log_p(x)>log_p_min then x unchanged. Otherwise x is moved (typically up the gradient) until log_p(x)>=log_p_min.
| x | This may be modified to the nearest plausible position. |
Implements pdf1d_pdf.
Definition at line 353 of file pdf1d_mixture.cxx.
| pdf1d_sampler * pdf1d_mixture::new_sampler | ( | ) | const [virtual] |
Return instance object for this PDF.
Return instance of this PDF.
Object is created on heap. Caller responsible for deletion.
Implements pdf1d_pdf.
Definition at line 75 of file pdf1d_mixture.cxx.
| double pdf1d_mixture::operator() | ( | double | x | ) | const [virtual] |
Probability density at x.
Reimplemented from pdf1d_pdf.
Definition at line 249 of file pdf1d_mixture.cxx.
| pdf1d_mixture & pdf1d_mixture::operator= | ( | const pdf1d_mixture & | m | ) |
Copy operator.
Definition at line 38 of file pdf1d_mixture.cxx.
| virtual double pdf1d_pdf::peak | ( | int | ) | const [inline, virtual, inherited] |
Position of the i'th peak.
Definition at line 51 of file pdf1d_pdf.h.
| void pdf1d_mixture::print_summary | ( | vcl_ostream & | os | ) | const [virtual] |
| void pdf1d_pdf::set_mean | ( | double | m | ) | [inline, protected, inherited] |
Reimplemented in pdf1d_gaussian.
Definition at line 31 of file pdf1d_pdf.h.
| void pdf1d_mixture::set_mean_and_variance | ( | double | m, |
| double | v | ||
| ) |
Set the whole pdf mean and variance values.
Components and Weights should already be correct so that the error checking can work. #define NDEBUG to turn off error checking.
Definition at line 148 of file pdf1d_mixture.cxx.
| void pdf1d_pdf::set_variance | ( | double | v | ) | [inline, protected, inherited] |
Definition at line 32 of file pdf1d_pdf.h.
| double pdf1d_pdf::variance | ( | ) | const [inline, inherited] |
Variance of each dimension.
Definition at line 45 of file pdf1d_pdf.h.
| short pdf1d_mixture::version_no | ( | ) | const |
Version number for I/O.
Reimplemented from pdf1d_pdf.
Definition at line 171 of file pdf1d_mixture.cxx.
| double pdf1d_mixture::weight | ( | unsigned | i | ) | const [inline] |
Get ith weight.
Definition at line 74 of file pdf1d_mixture.h.
| const vcl_vector<double>& pdf1d_mixture::weights | ( | ) | const [inline] |
| vcl_vector<double>& pdf1d_mixture::weights | ( | ) | [inline] |
Array of weights.
Warning care must be taken to ensure consistency when modifying weights Warning. Use weight(i) where possible
Definition at line 83 of file pdf1d_mixture.h.
| bool pdf1d_pdf::write_plot_file | ( | const vcl_string & | plot_file, |
| double | min_x, | ||
| double | max_x, | ||
| int | n | ||
| ) | const [inherited] |
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.
vcl_vector<pdf1d_pdf*> pdf1d_mixture::component_ [private] |
Definition at line 20 of file pdf1d_mixture.h.
vcl_vector<double> pdf1d_mixture::weight_ [private] |
Definition at line 21 of file pdf1d_mixture.h.
1.7.5.1