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

pdf1d_sampler Class Reference

#include <pdf1d_sampler.h>

Inheritance diagram for pdf1d_sampler:

Inheritance graph
[legend]
List of all members.

Detailed Description

Base class for Univariate Random Sampler classes.

This is really a random number generator whose outputs have the PDF of the relevant pdf1d_pdf. Sampler objects should only exist as long as their pdf object, and are not meant to be persistent.

Definition at line 23 of file pdf1d_sampler.h.

Public Member Functions

 pdf1d_sampler ()
 Dflt ctor.
virtual ~pdf1d_sampler ()
 Destructor.
const pdf1d_pdfmodel () const
 PDF of which this is an instance.
virtual void set_model (const pdf1d_pdf &)
 Set model for which this is an instance.
virtual double sample ()=0
 Draw random sample from distribution.
virtual void get_samples (vnl_vector< double > &x)
 Fill x with samples drawn from distribution.
virtual void regular_samples (vnl_vector< double > &x)
 Fill x with samples possibly chosen so as to represent the distribution.
virtual void regular_samples_and_prob (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 pdf1d_samplerclone () 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 pdf1d_pdfpdf_model_


Constructor & Destructor Documentation

pdf1d_sampler::pdf1d_sampler  ) 
 

Dflt ctor.

Definition at line 18 of file pdf1d_sampler.cxx.

pdf1d_sampler::~pdf1d_sampler  )  [virtual]
 

Destructor.

Definition at line 26 of file pdf1d_sampler.cxx.


Member Function Documentation

virtual pdf1d_sampler* pdf1d_sampler::clone  )  const [pure virtual]
 

Create a copy on the heap and return base class pointer.

Implemented in pdf1d_epanech_kernel_pdf_sampler, pdf1d_exponential_sampler, pdf1d_flat_sampler, pdf1d_gaussian_kernel_pdf_sampler, pdf1d_gaussian_sampler, pdf1d_mixture_sampler, and pdf1d_weighted_epanech_kernel_sampler.

void pdf1d_sampler::get_samples vnl_vector< double > &  x  )  [virtual]
 

Fill x with samples drawn from distribution.

Definition at line 45 of file pdf1d_sampler.cxx.

vcl_string pdf1d_sampler::is_a  )  const [virtual]
 

Name of the class.

Reimplemented in pdf1d_epanech_kernel_pdf_sampler, pdf1d_exponential_sampler, pdf1d_flat_sampler, pdf1d_gaussian_kernel_pdf_sampler, pdf1d_gaussian_sampler, pdf1d_mixture_sampler, and pdf1d_weighted_epanech_kernel_sampler.

Definition at line 82 of file pdf1d_sampler.cxx.

bool pdf1d_sampler::is_class vcl_string const &  s  )  const [virtual]
 

Does the name of the class match the argument?.

Reimplemented in pdf1d_epanech_kernel_pdf_sampler, pdf1d_exponential_sampler, pdf1d_flat_sampler, pdf1d_gaussian_kernel_pdf_sampler, pdf1d_gaussian_sampler, pdf1d_mixture_sampler, and pdf1d_weighted_epanech_kernel_sampler.

Definition at line 91 of file pdf1d_sampler.cxx.

const pdf1d_pdf & pdf1d_sampler::model  )  const
 

PDF of which this is an instance.

Definition at line 38 of file pdf1d_sampler.cxx.

void pdf1d_sampler::print_summary vcl_ostream &  os  )  const [virtual]
 

Print class to os.

Definition at line 101 of file pdf1d_sampler.cxx.

void pdf1d_sampler::regular_samples 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 pdf1d_epanech_kernel_pdf_sampler, pdf1d_exponential_sampler, pdf1d_flat_sampler, pdf1d_gaussian_kernel_pdf_sampler, pdf1d_gaussian_sampler, and pdf1d_weighted_epanech_kernel_sampler.

Definition at line 55 of file pdf1d_sampler.cxx.

void pdf1d_sampler::regular_samples_and_prob 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 65 of file pdf1d_sampler.cxx.

virtual void pdf1d_sampler::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 pdf1d_epanech_kernel_pdf_sampler, pdf1d_exponential_sampler, pdf1d_flat_sampler, pdf1d_gaussian_kernel_pdf_sampler, pdf1d_gaussian_sampler, pdf1d_mixture_sampler, and pdf1d_weighted_epanech_kernel_sampler.

virtual double pdf1d_sampler::sample  )  [pure virtual]
 

Draw random sample from distribution.

Implemented in pdf1d_epanech_kernel_pdf_sampler, pdf1d_exponential_sampler, pdf1d_flat_sampler, pdf1d_gaussian_kernel_pdf_sampler, pdf1d_gaussian_sampler, pdf1d_mixture_sampler, and pdf1d_weighted_epanech_kernel_sampler.

void pdf1d_sampler::set_model const pdf1d_pdf  )  [virtual]
 

Set model for which this is an instance.

Reimplemented in pdf1d_exponential_sampler, pdf1d_flat_sampler, pdf1d_gaussian_sampler, and pdf1d_mixture_sampler.

Definition at line 32 of file pdf1d_sampler.cxx.


Member Data Documentation

const pdf1d_pdf* pdf1d_sampler::pdf_model_ [protected]
 

Definition at line 26 of file pdf1d_sampler.h.


The documentation for this class was generated from the following files:
Generated on Thu Jan 10 14:43:24 2008 for contrib/mul/pdf1d by  doxygen 1.4.4