Show
Ignore:
Timestamp:
11/17/09 20:55:03 (15 years ago)
Author:
smidl
Message:

Reworked epdf_harness - testing is now more general.

Corrections of existing tests.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • library/bdm/stat/exp_family.cpp

    r725 r730  
    3838         
    3939        return concat (cvectorize(M),cvectorize(R.to_mat())); 
     40} 
     41 
     42mat 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; 
    4071} 
    4172