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