running_stat_proto.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2009 NICTA
00002 // 
00003 // Authors:
00004 // - Conrad Sanderson (conradsand at ieee dot org)
00005 // 
00006 // This file is part of the Armadillo C++ library.
00007 // It is provided without any warranty of fitness
00008 // for any purpose. You can redistribute this file
00009 // and/or modify it under the terms of the GNU
00010 // Lesser General Public License (LGPL) as published
00011 // by the Free Software Foundation, either version 3
00012 // of the License or (at your option) any later version.
00013 // (see http://www.opensource.org/licenses for more info)
00014 
00015 
00016 //! \addtogroup running_stat
00017 //! @{
00018 
00019 
00020 
00021 //! Class for keeping statistics of a continuously sampled process / signal.
00022 //! Useful if the storage of individual samples is not necessary or desired.
00023 //! Also useful if the number of samples is not known beforehand or exceeds 
00024 //! available memory.
00025 template<typename eT>
00026 class running_stat
00027   {
00028   public:
00029   
00030   typedef typename get_pod_type<eT>::pod_type T;
00031   
00032   
00033   inline      running_stat();
00034   
00035   inline void operator() (const T sample);
00036   inline void operator() (const std::complex<T>& sample);
00037 
00038   inline void reset();
00039   
00040   inline eT   mean() const;
00041   
00042   inline  T   var   (const u32 norm_type = 0) const;
00043   inline  T   stddev(const u32 norm_type = 0) const;
00044   
00045   inline eT   min()  const;
00046   inline eT   max()  const;
00047   
00048   //
00049   //
00050   
00051   private:
00052   
00053   arma_aligned  T  N;
00054   
00055   arma_aligned eT  acc1;
00056   arma_aligned  T  acc2;
00057   
00058   arma_aligned eT  min_val;
00059   arma_aligned eT  max_val;
00060   
00061   arma_aligned  T  min_val_norm;
00062   arma_aligned  T  max_val_norm;
00063 
00064 
00065   friend class running_stat_aux;
00066   };
00067 
00068 
00069 
00070 class running_stat_aux
00071   {
00072   public:
00073   
00074   template<typename eT>
00075   inline static void update_stats(running_stat<eT>&               x,  const eT               sample);
00076 
00077   template<typename T>
00078   inline static void update_stats(running_stat< std::complex<T> >& x, const T                sample);
00079 
00080   template<typename T>
00081   inline static void update_stats(running_stat< std::complex<T> >& x, const std::complex<T>& sample);
00082 
00083   //
00084 
00085   template<typename eT>
00086   inline static eT var(const running_stat<eT>&                x, const u32 norm_type = 0);
00087 
00088   template<typename T>
00089   inline static  T var(const running_stat< std::complex<T> >& x, const u32 norm_type = 0);
00090 
00091   };
00092 
00093 
00094 
00095 //! @}