00001 #ifndef pdf1d_mixture_sampler_h_ 00002 #define pdf1d_mixture_sampler_h_ 00003 //: 00004 // \file 00005 // \brief Implements sampling for a mixture model (a set of individual pdfs + weights) 00006 // \author Tim Cootes and Ian Scott 00007 00008 #include <vcl_vector.h> 00009 #include <pdf1d/pdf1d_sampler.h> 00010 #include <vnl/vnl_random.h> 00011 class pdf1d_mixture; 00012 00013 //: Instance class for pdf1d_mixture 00014 // Implements calculation of prob, gradient, sampling etc 00015 class pdf1d_mixture_sampler : public pdf1d_sampler 00016 { 00017 //: workspace 00018 vcl_vector<pdf1d_sampler*> inst_; 00019 00020 void init(); 00021 void delete_stuff(); 00022 00023 protected: 00024 //: The random number generator 00025 vnl_random rng_; 00026 public: 00027 00028 //: Dflt ctor 00029 pdf1d_mixture_sampler(); 00030 00031 //: Copy ctor 00032 pdf1d_mixture_sampler(const pdf1d_mixture_sampler&); 00033 00034 //: Copy operator 00035 pdf1d_mixture_sampler& operator=(const pdf1d_mixture_sampler&); 00036 00037 //: Destructor 00038 virtual ~pdf1d_mixture_sampler(); 00039 00040 //: Set model for which this is an instance 00041 virtual void set_model(const pdf1d_pdf&); 00042 00043 const pdf1d_mixture& mixture() const; 00044 00045 //: Draw random sample from distribution 00046 virtual double sample(); 00047 00048 //: Reseeds the static random number generator (one per derived class) 00049 virtual void reseed(unsigned long); 00050 00051 //: Version number for I/O 00052 short version_no() 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 pdf1d_sampler* clone() const; 00062 }; 00063 00064 #endif // pdf1d_mixture_sampler_h_