Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

Mvn.hh

Go to the documentation of this file.
00001 #ifndef MVN_HEADER
00002 #define MVN_HEADER
00003 
00004 // ==== HEADER Mvn.hh ====
00005 
00011 // 6-Jul-1999. Andras Aszodi
00012 
00013 // ==== STANDARD HEADERS ====
00014 
00015 #include <stdlib.h>
00016 #include <math.h>
00017 
00018 #ifdef _STANDARD_C_PLUS_PLUS
00019 #include <iostream>
00020 #include <iomanip>
00021 using namespace std;
00022 #else
00023 #include <iostream.h>
00024 #include <iomanip.h>
00025 #endif
00026 
00027 // ==== MODULE HEADERS ====
00028 
00029 #include "Vector.hh"
00030 #include "Rectmat.hh"
00031 #include "Symmat.hh"
00032 #include "Rangedimexc.hh"
00033 #include "Bits.hh"
00034 
00035 // ==== CLASSES ====
00036 
00037 namespace RazorBack {
00038 
00044 class Mvn_
00045 {
00046     // static data
00047     private:
00048             
00049     static const double TWO_PI;
00050     
00051     // data
00052     private:
00053             
00054     size_t Dim, Covrank;     
00055     Vecdbl_ Avgvec; 
00056     Smatdbl_ Covarmat;  
00057     Vecdbl_ Eval;   
00058     Rmatdbl_ Evec;  
00059     Rmatdbl_ Stdnmap;    
00060     double Normfactor;  
00061     
00062     // methods
00063     public:
00064          
00069     explicit Mvn_(size_t D=2);
00070     
00075     Mvn_(const Vecdbl_& Avg, const Smatdbl_& Cov);
00076     
00078     size_t dim() const { return Dim; }
00079     
00087     size_t dim(size_t D);
00088     
00093     size_t covrank() const { return Covrank; }
00094     
00096     const Vecdbl_& avg() const { return Avgvec; }
00097     
00099     void avg(const Vecdbl_& Newavg)
00100     {
00101         if (dim()!=Newavg.dim())
00102             throw Dimexc_("Mvn_::avg(Newavg)", dim(), Newavg.dim());
00103         Avgvec=Newavg;
00104     }
00105     
00107     const Smatdbl_& covar() const { return Covarmat; }
00108     
00115     int covar(const Smatdbl_& Newcov);
00116     
00121     double pdf(const Vecdbl_& X) const
00122     {
00123         return (Normfactor*exp(-maha_dist(X)/2.0));
00124     }
00125     
00132     void random(Vecdbl_& X) const;
00133     
00139     double maha_dist(const Vecdbl_& X) const;
00140     
00159     size_t marginal(const Bits_& Bitmask, Mvn_& Marginal) const;
00160     
00161         // I/O
00162     
00178     friend istream& operator>>(istream& In, Mvn_& Mvn);
00179     
00181     friend ostream& operator<<(ostream& Out, const Mvn_& Mvn);
00182     
00183 };
00184 // END OF CLASS Mvn_
00185 
00186 } // RazorBack
00187 
00188 // ==== END OF HEADER Mvn.hh ====
00189 
00190 #endif      // MVN_HEADER

Generated at Wed Aug 21 09:33:12 2002 for The Razorback C++ Library: Statistics by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001