Changeset 730 for library/bdm/stat
- Timestamp:
- 11/17/09 20:55:03 (15 years ago)
- Location:
- library/bdm/stat
- Files:
-
- 4 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/stat/discrete.cpp
r723 r730 122 122 } 123 123 124 void grid_fnc::set_values (const epdf &ep ) { 125 if ( sup.points() > 0 ) { 126 values ( 0 ) = exp(ep.evallog( sup.first_vec() )); 127 for ( int j = 1; j < sup.points(); j++ ) { 128 values ( j ) = exp(ep.evallog( sup.next_vec() )); 129 } 130 } 124 131 } 132 133 } -
library/bdm/stat/discrete.h
r706 r730 62 62 //! Get next active vector, call ONLY after first_vector()! 63 63 const vec& next_vec(); 64 64 65 //! return active vector, call ONLY after first_vector()! 66 const vec& act_vec(){return actvec;}; 67 65 68 //! \todo to je asi navic .. v predkovi! 66 69 ivec nearest_point ( const vec &val ); … … 140 143 //! constructor function fills values by calling function \c f , double f(vec&), given by a pointer 141 144 void set_values ( double ( *evalptr ) ( const vec& ) ); 142 145 146 //! constructor function fills values by calling function \c f , double f(vec&), given by a pointer 147 void set_values ( const epdf &ep); 148 143 149 //! get value nearest to the given point 144 150 double nearest_val ( const vec &val ) { … … 149 155 return vec_1 ( nearest_val ( val ) ); 150 156 } 157 const vec & _values() const { return values; } 151 158 }; 152 159 UIREGISTER ( grid_fnc ); -
library/bdm/stat/exp_family.cpp
r725 r730 38 38 39 39 return concat (cvectorize(M),cvectorize(R.to_mat())); 40 } 41 42 mat egiw::sample_mat(int n) const { 43 // TODO - correct approach - convert to product of norm * Wishart 44 mat M; 45 ldmat Vz; 46 ldmat Lam; 47 factorize(M,Vz,Lam); 48 49 chmat ChLam(Lam.to_mat()); 50 chmat iChLam; 51 ChLam.inv(iChLam); 52 53 eWishartCh Omega; //inverse Wishart, result is R, 54 Omega.set_parameters(iChLam,nu-2*nPsi-dimx); // 2*nPsi is there to match numercial simulations - check if analytically correct 55 56 mat OmChi; 57 mat Z(M.rows(),M.cols()); 58 59 mat Mi; 60 mat RChiT; 61 mat tmp(dimension(), n); 62 for (int i=0; i<n;i++){ 63 OmChi=Omega.sample_mat(); 64 RChiT=inv(OmChi); 65 Z=randn(M.rows(), M.cols()); 66 Mi = M + RChiT * Z * inv(Vz._L().T() *diag(sqrt(Vz._D()))); 67 68 tmp.set_col(i,concat (cvectorize(Mi),cvectorize(RChiT*RChiT.T()))); 69 } 70 return tmp; 40 71 } 41 72 -
library/bdm/stat/exp_family.h
r728 r730 221 221 222 222 vec sample() const; 223 mat sample_mat(int n) const; 223 224 vec mean() const; 224 225 vec variance() const;