Base class for Multi-Variate Random Sampler classes. More...
#include <vpdfl_sampler_base.h>
Public Member Functions | |
vpdfl_sampler_base () | |
virtual | ~vpdfl_sampler_base () |
const vpdfl_pdf_base & | model () const |
PDF of which this is an instance. | |
virtual void | set_model (const vpdfl_pdf_base &) |
Set model for which this is an instance. | |
virtual void | sample (vnl_vector< double > &x)=0 |
Draw random sample from distribution. | |
virtual void | get_samples (vcl_vector< vnl_vector< double > > &x) |
Fill x with samples drawn from distribution. | |
virtual void | regular_samples (vcl_vector< vnl_vector< double > > &x) |
Fill x with samples possibly chosen so as to represent the distribution. | |
virtual void | regular_samples_and_prob (vcl_vector< vnl_vector< double > > &x, vnl_vector< double > &p) |
Fill x with samples possibly chosen so as to represent the distribution. | |
virtual void | reseed (unsigned long)=0 |
Reseeds the internal random number generator. | |
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 vpdfl_sampler_base * | clone () const =0 |
Create a copy on the heap and return base class pointer. | |
virtual void | print_summary (vcl_ostream &os) const |
Print class to os. | |
Protected Attributes | |
const vpdfl_pdf_base * | pdf_model_ |
Base class for Multi-Variate Random Sampler classes.
This is really a multivariate random number generator whose outputs have the PDF of the relevant vpdfl_pdf_base. Sampler objects should only exist as long as their pdf object, and are not meant to be persistent.
Definition at line 28 of file vpdfl_sampler_base.h.
vpdfl_sampler_base::vpdfl_sampler_base | ( | ) |
Definition at line 20 of file vpdfl_sampler_base.cxx.
vpdfl_sampler_base::~vpdfl_sampler_base | ( | ) | [virtual] |
Definition at line 28 of file vpdfl_sampler_base.cxx.
virtual vpdfl_sampler_base* vpdfl_sampler_base::clone | ( | ) | const [pure virtual] |
Create a copy on the heap and return base class pointer.
Implemented in vpdfl_gaussian_kernel_pdf_sampler, vpdfl_mixture_sampler, vpdfl_axis_gaussian_sampler, vpdfl_gaussian_sampler, and vpdfl_pc_gaussian_sampler.
void vpdfl_sampler_base::get_samples | ( | vcl_vector< vnl_vector< double > > & | x | ) | [virtual] |
Fill x with samples drawn from distribution.
Definition at line 48 of file vpdfl_sampler_base.cxx.
vcl_string vpdfl_sampler_base::is_a | ( | ) | const [virtual] |
Name of the class.
Reimplemented in vpdfl_gaussian_kernel_pdf_sampler, vpdfl_mixture_sampler, vpdfl_axis_gaussian_sampler, vpdfl_gaussian_sampler, and vpdfl_pc_gaussian_sampler.
Definition at line 85 of file vpdfl_sampler_base.cxx.
bool vpdfl_sampler_base::is_class | ( | vcl_string const & | s | ) | const [virtual] |
Does the name of the class match the argument?.
Reimplemented in vpdfl_gaussian_kernel_pdf_sampler, vpdfl_mixture_sampler, vpdfl_axis_gaussian_sampler, vpdfl_gaussian_sampler, and vpdfl_pc_gaussian_sampler.
Definition at line 94 of file vpdfl_sampler_base.cxx.
const vpdfl_pdf_base & vpdfl_sampler_base::model | ( | ) | const |
PDF of which this is an instance.
Definition at line 40 of file vpdfl_sampler_base.cxx.
void vpdfl_sampler_base::print_summary | ( | vcl_ostream & | os | ) | const [virtual] |
Print class to os.
Definition at line 104 of file vpdfl_sampler_base.cxx.
void vpdfl_sampler_base::regular_samples | ( | vcl_vector< vnl_vector< double > > & | x | ) | [virtual] |
Fill x with samples possibly chosen so as to represent the distribution.
Generate a set of pseudo-random samples, chosen so as to be suitable to represent the distribution. This is meant to be used for estimating continuous integrals with sampled approximations. Where there are multiple peaks (e.g. kernel or mixture models), it is preferred that the number of samples from each component is roughly proportional to the weight for the component. When small numbers are requested, this can be done explicitly. The default is simply to call sample() for each element of x
Reimplemented in vpdfl_gaussian_kernel_pdf_sampler.
Definition at line 57 of file vpdfl_sampler_base.cxx.
void vpdfl_sampler_base::regular_samples_and_prob | ( | vcl_vector< vnl_vector< double > > & | x, |
vnl_vector< double > & | p | ||
) | [virtual] |
Fill x with samples possibly chosen so as to represent the distribution.
As regular_samples(x), but p[i] is set to p(x[i])
Definition at line 67 of file vpdfl_sampler_base.cxx.
virtual void vpdfl_sampler_base::reseed | ( | unsigned | long | ) | [pure virtual] |
Reseeds the internal random number generator.
To achieve quasi-random initialisation use;
#include <vcl_ctime.h>
..
sampler.reseed(vcl_time(0));
Implemented in vpdfl_gaussian_kernel_pdf_sampler, vpdfl_mixture_sampler, vpdfl_axis_gaussian_sampler, and vpdfl_gaussian_sampler.
virtual void vpdfl_sampler_base::sample | ( | vnl_vector< double > & | x | ) | [pure virtual] |
Draw random sample from distribution.
Implemented in vpdfl_mixture_sampler, vpdfl_gaussian_kernel_pdf_sampler, vpdfl_axis_gaussian_sampler, and vpdfl_gaussian_sampler.
void vpdfl_sampler_base::set_model | ( | const vpdfl_pdf_base & | model | ) | [virtual] |
Set model for which this is an instance.
Reimplemented in vpdfl_mixture_sampler, vpdfl_axis_gaussian_sampler, and vpdfl_gaussian_kernel_pdf_sampler.
Definition at line 34 of file vpdfl_sampler_base.cxx.
const vpdfl_pdf_base* vpdfl_sampler_base::pdf_model_ [protected] |
Definition at line 31 of file vpdfl_sampler_base.h.