Changeset 730 for library/bdm/stat

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.

Location:
library/bdm/stat
Files:
4 modified

Legend:

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

    r723 r730  
    122122} 
    123123 
     124void 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        } 
    124131} 
     132 
     133} 
  • library/bdm/stat/discrete.h

    r706 r730  
    6262        //! Get next active vector, call ONLY after first_vector()! 
    6363        const vec& next_vec(); 
    64  
     64         
     65        //! return active vector, call ONLY after first_vector()! 
     66        const vec& act_vec(){return actvec;}; 
     67         
    6568        //! \todo to je asi navic .. v predkovi! 
    6669        ivec nearest_point ( const vec &val ); 
     
    140143        //! constructor function fills values by calling function \c f , double f(vec&), given by a pointer 
    141144        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         
    143149        //! get value nearest to the given point 
    144150        double nearest_val ( const vec &val ) { 
     
    149155                return vec_1 ( nearest_val ( val ) ); 
    150156        } 
     157        const vec & _values() const { return values; } 
    151158}; 
    152159UIREGISTER ( grid_fnc ); 
  • 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 
  • library/bdm/stat/exp_family.h

    r728 r730  
    221221 
    222222                vec sample() const; 
     223                mat sample_mat(int n) const; 
    223224                vec mean() const; 
    224225                vec variance() const;