contrib/brl/bbas/bsta/algo/bsta_parzen_updater.h
Go to the documentation of this file.
00001 // This is brl/bbas/bsta/algo/bsta_parzen_updater.h
00002 #ifndef bsta_parzen_updater_h_
00003 #define bsta_parzen_updater_h_
00004 //:
00005 // \file
00006 // \brief Parzen updaters
00007 // \author Joseph L. Mundy
00008 // \date October 13, 2008
00009 //
00010 // This file contains updaters based on
00011 // Parzen distributions
00012 //
00013 // \verbatim
00014 //  Modifications
00015 //   (none yet)
00016 // \endverbatim
00017 //
00018 // Do not remove the following statement
00019 // Approved for Public Release, Distribution Unlimited (DISTAR Case 12529)
00020 
00021 #include <bsta/bsta_parzen_sphere.h>
00022 #include <vcl_algorithm.h>
00023 #include <vcl_cmath.h>
00024 #include <vcl_vector.h>
00025 
00026 //: A parzen window (kernel) updater.
00027 // If a new sample is within tol of the existing samples then don't insert.
00028 // Otherwise if max number of samples is reached, replace the nearest sample.
00029 template <class parzen_dist_>
00030 class bsta_parzen_updater
00031 {
00032  public:
00033   typedef typename parzen_dist_::math_type T;
00034   typedef typename parzen_dist_::vector_type vector_;
00035   enum { data_dimension = parzen_dist_::dimension };
00036 
00037   //: for compatibility with vpdl/vpdt
00038   typedef typename parzen_dist_::field_type field_type;
00039 
00040   // Constructor
00041   bsta_parzen_updater(T tol, unsigned max_samples)
00042   : tol_(tol), max_samples_(max_samples) {}
00043 
00044   //: The update functor
00045   void operator() (parzen_dist_& pdist, const vector_& sample) const;
00046  private:
00047   T tol_;
00048   unsigned max_samples_;
00049 };
00050 
00051 //: A parzen window (kernel) updater.
00052 // If a new sample is within tol of the existing samples then don't insert.
00053 // Otherwise if maximum number of samples has been reached, then compute a new
00054 // bandwidth estimate based on the most probable fraction of the existing
00055 // samples.
00056 template <class parzen_dist_>
00057 class bsta_parzen_adapt_bw_updater
00058 {
00059  public:
00060   typedef typename parzen_dist_::math_type T;
00061   typedef typename parzen_dist_::vector_type vector_;
00062   enum { data_dimension = parzen_dist_::dimension };
00063 
00064   //: for compatibility with vpdl/vpdt
00065   typedef typename parzen_dist_::field_type field_type;
00066   typedef parzen_dist_ distribution_type;
00067 
00068 
00069   // Constructor
00070   bsta_parzen_adapt_bw_updater(T tol, unsigned max_samples,
00071                                T frac_backgnd = T(1))
00072   : tol_(tol), max_samples_(max_samples),
00073     frac_background_(frac_backgnd) {}
00074 
00075   //: The update functor
00076   void operator() (parzen_dist_& pdist, const vector_& sample) const;
00077  private:
00078   T tol_;
00079   unsigned max_samples_;
00080   T frac_background_;
00081 };
00082 
00083 #endif // bsta_parzen_updater_h_