contrib/mul/vpdfl/vpdfl_gaussian_kernel_pdf_sampler.h
Go to the documentation of this file.
00001 // This is mul/vpdfl/vpdfl_gaussian_kernel_pdf_sampler.h
00002 #ifndef vpdfl_gaussian_kernel_pdf_sampler_h
00003 #define vpdfl_gaussian_kernel_pdf_sampler_h
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \author Tim Cootes
00010 // \brief Sampler class for gaussian kernel PDF.
00011 
00012 #include <vcl_string.h>
00013 #include <vnl/vnl_fwd.h>
00014 #include <vnl/vnl_random.h>
00015 #include <vpdfl/vpdfl_sampler_base.h>
00016 class vpdfl_gaussian_kernel_pdf;
00017 
00018 //=======================================================================
00019 
00020 //: Samples from an axis aligned Gaussian PDF
00021 class vpdfl_gaussian_kernel_pdf_sampler :public vpdfl_sampler_base
00022 {
00023  protected:
00024   //: The random number generator
00025   vnl_random rng_; 
00026  public:
00027 
00028   // Dflt ctor
00029   vpdfl_gaussian_kernel_pdf_sampler();
00030 
00031   // Destructor
00032   virtual ~vpdfl_gaussian_kernel_pdf_sampler();
00033 
00034   //: Set model for which this is an instance
00035   // Error check that it is an axis gaussian.
00036   virtual void set_model(const vpdfl_pdf_base&);
00037 
00038   //: Draw random sample from j-th component of distribution
00039   void sample_component(vnl_vector<double>& x, int j);
00040 
00041   //: Draw random sample from distribution
00042   virtual void sample(vnl_vector<double>& x);
00043 
00044   //: Fill x with samples possibly chosen so as to represent the distribution
00045   //  Sample sequentially from each component.
00046   virtual void regular_samples(vcl_vector<vnl_vector<double> >& x);
00047 
00048   //: Reseeds the internal random number generator
00049   // To achieve quasi-random initialisation use;
00050   // \code
00051   // #include <vcl_ctime.h>
00052   // ..
00053   // sampler.reseed(vcl_time(0));
00054   // \endcode
00055   virtual void reseed(unsigned long);
00056 
00057 
00058   //: Return a reference to the pdf model
00059   // This is properly cast.
00060   const vpdfl_gaussian_kernel_pdf& gaussian_kernel_pdf() const;
00061 
00062   //: Name of the class
00063   virtual vcl_string is_a() const;
00064 
00065   //: Does the name of the class match the argument?
00066   virtual bool is_class(vcl_string const& s) const;
00067 
00068   //: Create a copy on the heap and return base class pointer
00069   virtual vpdfl_sampler_base* clone() const;
00070 };
00071 
00072 #endif // vpdfl_gaussian_kernel_pdf_sampler_h