contrib/mul/pdf1d/pdf1d_compare_to_pdf_bhat.h
Go to the documentation of this file.
00001 // This is mul/pdf1d/pdf1d_compare_to_pdf_bhat.h
00002 #ifndef pdf1d_compare_to_pdf_bhat_h
00003 #define pdf1d_compare_to_pdf_bhat_h
00004 
00005 //:
00006 // \file
00007 // \author Tim Cootes
00008 // \brief Test if data from a given distribution using Bhattacharyya overlap
00009 
00010 #include <pdf1d/pdf1d_compare_to_pdf.h>
00011 #include <mbl/mbl_cloneable_ptr.h>
00012 #include <vcl_iosfwd.h>
00013 
00014 //: Test if data from a given distribution using Bhattacharyya overlap
00015 //  Uses builder() to build a pdf from supplied data.  This is then
00016 //  tested against the target distribution using an estimate of the
00017 //  Bhattacharyya overlap.
00018 class pdf1d_compare_to_pdf_bhat : public pdf1d_compare_to_pdf
00019 {
00020   //: Define method of building pdf from data
00021   mbl_cloneable_ptr<pdf1d_builder> builder_;
00022 
00023   //: Number of samples per data-point used in estimating overlap
00024   int n_per_point_;
00025  public:
00026 
00027   //: Dflt ctor
00028   pdf1d_compare_to_pdf_bhat();
00029 
00030   //: Construct and define method of building pdf from data
00031   // \param n_per_point : Number of samples per data-point used in estimating overlap
00032   pdf1d_compare_to_pdf_bhat(const pdf1d_builder& builder, int n_per_point);
00033 
00034   //: Destructor
00035   virtual ~pdf1d_compare_to_pdf_bhat();
00036 
00037   //: Define method of building pdf from data
00038   void set_builder(const pdf1d_builder&);
00039 
00040   //: Method of building pdf from data
00041   const pdf1d_builder& builder() const { return builder_; }
00042 
00043   //: Number of samples per data-point used in estimating overlap
00044   int n_per_point() const { return n_per_point_; }
00045 
00046   //: Number of samples per data-point used in estimating overlap
00047   void set_n_per_point(int n);
00048 
00049 
00050   //: Test whether data came from the given distribution
00051   virtual double compare(const double* data, int n, const pdf1d_pdf& pdf);
00052 
00053   //: Test whether data has form of the given distribution
00054   //  Repeatedly resamples n values from data[0..n-1] and
00055   //  calls compare_form().
00056   //  Individual comparisons are returned in B.
00057   //  \return Mean of B
00058   virtual double bootstrap_compare_form(vnl_vector<double>& B,
00059                                         const double* data, int n,
00060                                         const pdf1d_builder& builder, int n_trials);
00061 
00062   //: Version number for I/O
00063   short version_no() const;
00064 
00065   //: Name of the class
00066   virtual vcl_string is_a() const;
00067 
00068   //: Does the name of the class match the argument?
00069   virtual bool is_class(vcl_string const& s) const;
00070 
00071   //: Create a copy on the heap and return base class pointer
00072   virtual pdf1d_compare_to_pdf* clone() const;
00073 
00074   //: Print class to os
00075   virtual void print_summary(vcl_ostream& os) const;
00076 
00077   //: Save class to binary file stream
00078   virtual void b_write(vsl_b_ostream& bfs) const;
00079 
00080   //: Load class from binary file stream
00081   virtual void b_read(vsl_b_istream& bfs);
00082 };
00083 
00084 #endif // pdf1d_compare_to_pdf_bhat_h