00001 // This is mul/vpdfl/vpdfl_gaussian_sampler.h 00002 #ifndef vpdfl_gaussian_sampler_h 00003 #define vpdfl_gaussian_sampler_h 00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE 00005 #pragma interface 00006 #endif 00007 //: 00008 // \file 00009 // \author Ian Scott 00010 // \date 19-Apr-2001 00011 // \brief Sampler class for Multi-Variate Gaussian. 00012 00013 #include <vcl_string.h> 00014 #include <vcl_iosfwd.h> 00015 #include <vnl/vnl_fwd.h> 00016 #include <vnl/vnl_random.h> 00017 #include <vpdfl/vpdfl_sampler_base.h> 00018 class vpdfl_gaussian; 00019 00020 //======================================================================= 00021 00022 //: Samples from a Gaussian PDF 00023 class vpdfl_gaussian_sampler :public vpdfl_sampler_base 00024 { 00025 protected: 00026 //: The random number generator 00027 vnl_random rng_; 00028 //: workspace variable 00029 vnl_vector<double> b_; 00030 public: 00031 00032 //: Dflt ctor 00033 vpdfl_gaussian_sampler(); 00034 00035 //: Destructor 00036 virtual ~vpdfl_gaussian_sampler(); 00037 00038 //: Draw random sample from Gaussian distribution 00039 virtual void sample(vnl_vector<double>& x); 00040 00041 //: Reseeds the internal random number generator 00042 // To achieve quasi-random initialisation use; 00043 // \code 00044 // #include <vcl_ctime.h> 00045 // .. 00046 // sampler.reseed(vcl_time(0)); 00047 // \endcode 00048 virtual void reseed(unsigned long); 00049 00050 //: Return a reference to the pdf model 00051 // This is properly cast. 00052 const vpdfl_gaussian& gaussian() const; 00053 00054 //: Name of the class 00055 virtual vcl_string is_a() const; 00056 00057 //: Does the name of the class match the argument? 00058 virtual bool is_class(vcl_string const& s) const; 00059 00060 //: Create a copy on the heap and return base class pointer 00061 virtual vpdfl_sampler_base* clone() const; 00062 }; 00063 00064 //: Stream output operator for class reference 00065 vcl_ostream& operator<<(vcl_ostream& os,const vpdfl_gaussian_sampler& b); 00066 00067 //: Stream output operator for class pointer 00068 vcl_ostream& operator<<(vcl_ostream& os,const vpdfl_gaussian_sampler* b); 00069 00070 #endif // vpdfl_gaussian_sampler_h