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