contrib/rpl/rrel/rrel_muse_table.h
Go to the documentation of this file.
00001 #ifndef rrel_muse_table_h_
00002 #define rrel_muse_table_h_
00003 //:
00004 //  \file
00005 //  \author Chuck Stewart
00006 //  \date   Summer 2001
00007 //  \date   Modufied May 2004 to store the values in a map
00008 //  \brief  Look-up table for the normalization terms used in the MUSE objective function.
00009 //
00010 
00011 #include <vcl_map.h>
00012 
00013 //: Look-up table for the MUSET objective function.
00014 //  Look-up table for the MUSET objective function, derived in James
00015 //  V. Miller's 1997 PhD dissertation at Rensselaer.  An earlier
00016 //  version of appeared in CVPR 1996.  The class computes and stores
00017 //  statistics on the order statistics of Gaussian random variates.
00018 //  Actually, these are for the order statistics of the absolute
00019 //  values of Gaussian random variates.  See rrel_muset_obj for more
00020 //  details.
00021 
00022 class rrel_muse_key_type
00023 {
00024  public:
00025   rrel_muse_key_type( unsigned int k, unsigned int n ) : k_(k), n_(n) {}
00026   unsigned int k_;
00027   unsigned int n_;
00028 };
00029 
00030 bool operator< ( rrel_muse_key_type const& left_t, rrel_muse_key_type const& right_t );
00031 
00032 
00033 class rrel_muse_table_entry
00034 {
00035  public:
00036   rrel_muse_table_entry() : initialized_(false) {}
00037   bool initialized_;
00038   double expected_;
00039   double standard_dev_;
00040   double muse_t_divisor_;
00041   double muse_t_sq_divisor_;
00042 };
00043 
00044 typedef vcl_map< rrel_muse_key_type, rrel_muse_table_entry > rrel_muse_map_type;
00045 
00046 
00047 class rrel_muse_table
00048 {
00049  public:
00050   //: Constructor.
00051   //  \a table_size is the size of table (= max number of residuals
00052   //  pre-computed).
00053   rrel_muse_table( unsigned int /* max_n_stored */ ) {}
00054 
00055   rrel_muse_table( ) {}
00056 
00057   //: Destructor
00058   ~rrel_muse_table() {}
00059 
00060   //: Expected value of the kth ordered residual from n samples.
00061   //  The value is retrieved from the lookup table when possible.
00062   double expected_kth( unsigned int k, unsigned int n );
00063 
00064   //: Standard deviation of the kth ordered residual from n samples.
00065   //  The value is retrieved from the lookup table when possible.
00066   double standard_dev_kth( unsigned int k, unsigned int n );
00067 
00068   //: The divisor for trimmed statistics.
00069   //  The value is retrieved from the lookup table when possible.
00070   double muset_divisor( unsigned int k, unsigned int n );
00071 
00072 
00073   //: The divisor for trimmed square statistics.
00074   //  The value is retrieved from the lookup table when possible.
00075   double muset_sq_divisor( unsigned int k, unsigned int n );
00076 
00077  private:
00078   void calculate_all( unsigned int k, unsigned int n, rrel_muse_table_entry & entry );
00079 
00080   //: Expected value of the kth ordered residual from n samples.
00081   //  The value is computed "from scratch".
00082   double calculate_expected( unsigned int k, unsigned int n ) const;
00083 
00084   //: Standard deviation of the kth ordered residual from n samples.
00085   //  The value is computed "from scratch".
00086   double calculate_standard_dev( unsigned int k, unsigned int n, double expected_kth ) const;
00087 
00088   //: The divisor for trimmed statistics.
00089   //  The value is computed "from scratch".
00090   double calculate_divisor( unsigned int k, unsigned int n, double expected_kth ) const;
00091 
00092   //: The divisor for trimmed squared statistics.
00093   //  The value is computed "from scratch".
00094   double calculate_sq_divisor( unsigned int k, unsigned int n, double expected_kth ) const;
00095 
00096  private:
00097   rrel_muse_map_type table_;
00098 };
00099 
00100 #endif // rrel_muse_table_h_