Changeset 450
- Timestamp:
- 07/29/09 15:39:19 (16 years ago)
- Location:
- library
- Files:
-
- 4 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/stat/exp_family.h
r429 r450 142 142 143 143 vec sample() const; 144 mat sample ( int N ) const; 144 145 145 double evallog_nn ( const vec &val ) const; 146 146 double lognc () const; … … 1209 1209 }; 1210 1210 1211 template<class sq_T>1212 mat enorm<sq_T>::sample ( int N ) const1213 {1214 mat X ( dim,N );1215 vec x ( dim );1216 vec pom;1217 int i;1218 1219 for ( i=0;i<N;i++ )1220 {1221 #pragma omp critical1222 NorRNG.sample_vector ( dim,x );1223 pom = R.sqrt_mult ( x );1224 pom +=mu;1225 X.set_col ( i, pom );1226 }1227 1228 return X;1229 };1230 1231 1211 // template<class sq_T> 1232 1212 // double enorm<sq_T>::eval ( const vec &val ) const { -
library/tests/enorm.cfg
r444 r450 16 16 support = ( "matrix", 2, 2, [ -5.0, 5.0, -5.0, 5.0 ] ); 17 17 integral = 1.0; 18 R = ( "matrix", 2, 2, [ 1.0, -0.5, -0.5, 2.0 ] ); 18 19 }, 19 20 { -
library/tests/enorm_test.cpp
r448 r450 56 56 } 57 57 } 58 59 TEST(test_enorm_sample) {60 RNG_randomize();61 62 // Setup model63 vec mu("1.1 -1");64 ldmat R(mat("1 -0.5; -0.5 2"));65 66 RV x("{x }");67 RV y("{y }");68 69 enorm<ldmat> E;70 E.set_rv(concat(x, y));71 E.set_parameters(mu, R);72 73 int n = 1000;74 vec ll(n);75 mat smp = E.sample(1000);76 vec emu = sum(smp, 2) / n;77 CHECK_CLOSE(mu, emu, 0.3);78 79 mat er = (smp * smp.T()) / n - outer_product(emu, emu);80 CHECK_CLOSE(R.to_mat(), er, 0.3);81 } -
library/tests/testSmp.cpp
r394 r450 34 34 enorm<ldmat> eN; 35 35 eN.set_parameters(mu0,R); 36 mat Smp = eN.sample (N);36 mat Smp = eN.sample_m(N); 37 37 38 38 disp(mu0,R.to_mat(),Smp);