- Timestamp:
- 08/12/09 09:27:40 (15 years ago)
- Location:
- library
- Files:
-
- 11 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/base/bdmbase.cpp
r502 r504 134 134 } 135 135 136 shared_ptr<mpdf> epdf::condition (const RV &rv) const { 137 it_warning ("Not implemented"); 138 return shared_ptr<mpdf>(); 139 } 140 141 shared_ptr<epdf> epdf::marginal (const RV &rv) const { 142 it_warning ("Not implemented"); 143 return shared_ptr<epdf>(); 144 } 145 136 146 mat epdf::sample_m ( int N ) const { 137 147 mat X = zeros ( dim, N ); -
library/bdm/base/bdmbase.h
r502 r504 317 317 318 318 //! Return conditional density on the given RV, the remaining rvs will be in conditioning 319 virtual mpdf* condition (const RV &rv) const { 320 it_warning ("Not implemented"); 321 return NULL; 322 } 319 virtual shared_ptr<mpdf> condition (const RV &rv) const; 323 320 324 321 //! Return marginal density on the given RV, the remainig rvs are intergrated out 325 virtual epdf* marginal (const RV &rv) const { 326 it_warning ("Not implemented"); 327 return NULL; 328 } 322 virtual shared_ptr<epdf> marginal (const RV &rv) const; 329 323 330 324 //! return expected value -
library/bdm/estim/mixtures.cpp
r477 r504 142 142 143 143 emix* MixEF::epredictor ( ) const { 144 Array< epdf*> pC ( n );144 Array<shared_ptr<epdf> > pC ( n ); 145 145 for ( int i = 0; i < n; i++ ) { 146 146 pC ( i ) = Coms ( i )->epredictor ( ); … … 148 148 emix* tmp; 149 149 tmp = new emix( ); 150 tmp->set_parameters ( weights.posterior().mean(), pC, false ); 151 tmp->ownComs(); 150 tmp->set_parameters ( weights.posterior().mean(), pC ); 152 151 return tmp; 153 152 } -
library/bdm/stat/emix.cpp
r488 r504 3 3 namespace bdm { 4 4 5 void emix::set_parameters ( const vec &w0, const Array< epdf*> &Coms0, bool copy) {5 void emix::set_parameters ( const vec &w0, const Array<shared_ptr<epdf> > &Coms0 ) { 6 6 w = w0 / sum ( w0 ); 7 7 dim = Coms0 ( 0 )->dimension(); … … 14 14 it_assert_debug ( dim == ( Coms0 ( i )->dimension() ), "Component sizes do not match!" ); 15 15 it_assert_debug ( !isnamed || tmp_rv.equal ( Coms0 ( i )->_rv() ), "Component RVs do not match!" ); 16 } 17 18 Coms = Coms0; 19 20 if ( isnamed ) epdf::set_rv ( tmp_rv ); //coms aer already OK, no need for set_rv 21 } 22 23 vec emix::sample() const { 24 //Sample which component 25 vec cumDist = cumsum ( w ); 26 double u0; 27 #pragma omp critical 28 u0 = UniRNG.sample(); 29 30 int i = 0; 31 while ( ( cumDist ( i ) < u0 ) && ( i < ( w.length() - 1 ) ) ) { 32 i++; 33 } 34 35 return Coms ( i )->sample(); 36 } 37 38 shared_ptr<epdf> emix::marginal ( const RV &rv ) const { 39 emix *tmp = new emix(); 40 shared_ptr<epdf> narrow(tmp); 41 marginal ( rv, *tmp ); 42 return narrow; 43 } 44 45 void emix::marginal ( const RV &rv, emix &target ) const { 46 it_assert_debug ( isnamed(), "rvs are not assigned" ); 47 48 Array<shared_ptr<epdf> > Cn ( Coms.length() ); 49 for ( int i = 0; i < Coms.length(); i++ ) { 50 Cn ( i ) = Coms ( i )->marginal ( rv ); 51 } 52 53 target.set_parameters ( w, Cn ); 54 } 55 56 shared_ptr<mpdf> emix::condition ( const RV &rv ) const { 57 it_assert_debug ( isnamed(), "rvs are not assigned" ); 58 mratio *tmp = new mratio ( this, rv ); 59 return shared_ptr<mpdf>(tmp); 60 } 61 62 void egiwmix::set_parameters ( const vec &w0, const Array<egiw*> &Coms0, bool copy ) { 63 w = w0 / sum ( w0 ); 64 dim = Coms0 ( 0 )->dimension(); 65 int i; 66 for ( i = 0; i < w.length(); i++ ) { 67 it_assert_debug ( dim == ( Coms0 ( i )->dimension() ), "Component sizes do not match!" ); 16 68 } 17 69 if ( copy ) { … … 26 78 destroyComs = false; 27 79 } 28 if ( isnamed ) epdf::set_rv ( tmp_rv ); //coms aer already OK, no need for set_rv29 }30 31 vec emix::sample() const {32 //Sample which component33 vec cumDist = cumsum ( w );34 double u0;35 #pragma omp critical36 u0 = UniRNG.sample();37 38 int i = 0;39 while ( ( cumDist ( i ) < u0 ) && ( i < ( w.length() - 1 ) ) ) {40 i++;41 }42 43 return Coms ( i )->sample();44 }45 46 emix* emix::marginal ( const RV &rv ) const {47 it_assert_debug ( isnamed(), "rvs are not assigned" );48 49 Array<epdf*> Cn ( Coms.length() );50 for ( int i = 0; i < Coms.length(); i++ ) {51 Cn ( i ) = Coms ( i )->marginal ( rv );52 }53 emix* tmp = new emix();54 tmp->set_parameters ( w, Cn, false );55 tmp->ownComs();56 return tmp;57 }58 59 mratio* emix::condition ( const RV &rv ) const {60 it_assert_debug ( isnamed(), "rvs are not assigned" );61 return new mratio ( this, rv );62 };63 64 void egiwmix::set_parameters ( const vec &w0, const Array<egiw*> &Coms0, bool copy ) {65 w = w0 / sum ( w0 );66 dim = Coms0 ( 0 )->dimension();67 int i;68 for ( i = 0; i < w.length(); i++ ) {69 it_assert_debug ( dim == ( Coms0 ( i )->dimension() ), "Component sizes do not match!" );70 }71 if ( copy ) {72 Coms.set_length ( Coms0.length() );73 for ( i = 0; i < w.length(); i++ ) {74 it_error ( "Not imp..." );75 *Coms ( i ) = *Coms0 ( i );76 }77 destroyComs = true;78 } else {79 Coms = Coms0;80 destroyComs = false;81 }82 80 } 83 81 … … 118 116 } 119 117 120 emix* egiwmix::marginal ( const RV &rv ) const { 118 shared_ptr<epdf> egiwmix::marginal ( const RV &rv ) const { 119 emix *tmp = new emix(); 120 shared_ptr<epdf> narrow(tmp); 121 marginal ( rv, *tmp ); 122 return narrow; 123 } 124 125 void egiwmix::marginal ( const RV &rv, emix &target ) const { 121 126 it_assert_debug ( isnamed(), "rvs are not assigned" ); 122 127 123 Array< epdf*> Cn ( Coms.length() );128 Array<shared_ptr<epdf> > Cn ( Coms.length() ); 124 129 for ( int i = 0; i < Coms.length(); i++ ) { 125 130 Cn ( i ) = Coms ( i )->marginal ( rv ); 126 131 } 127 emix* tmp = new emix(); 128 tmp->set_parameters ( w, Cn, false ); 129 tmp->ownComs(); 130 return tmp; 132 133 target.set_parameters ( w, Cn ); 131 134 } 132 135 -
library/bdm/stat/emix.h
r503 r504 39 39 //! Nominator in the form of mpdf 40 40 const epdf* nom; 41 41 42 //!Denominator in the form of epdf 42 epdf* den; 43 shared_ptr<epdf> den; 44 43 45 //!flag for destructor 44 46 bool destroynom; … … 85 87 //! Default destructor 86 88 ~mratio() { 87 delete den;88 89 if ( destroynom ) { 89 90 delete nom; … … 107 108 vec w; 108 109 //! Component (epdfs) 109 Array<epdf*> Coms; 110 //!Flag if owning Coms 111 bool destroyComs; 110 Array<shared_ptr<epdf> > Coms; 111 112 112 public: 113 113 //!Default constructor … … 115 115 //! Set weights \c w and components \c Coms 116 116 //!By default Coms are copied inside. Parameter \c copy can be set to false if Coms live externally. Use method ownComs() if Coms should be destroyed by the destructor. 117 void set_parameters ( const vec &w, const Array< epdf*> &Coms, bool copy = false);117 void set_parameters ( const vec &w, const Array<shared_ptr<epdf> > &Coms ); 118 118 119 119 vec sample() const; … … 164 164 }; 165 165 166 emix* marginal ( const RV &rv ) const; 167 mratio* condition ( const RV &rv ) const; //why not mratio!! 166 shared_ptr<epdf> marginal ( const RV &rv ) const; 167 void marginal ( const RV &rv, emix &target ) const; 168 shared_ptr<mpdf> condition ( const RV &rv ) const; 168 169 169 170 //Access methods … … 172 173 return w; 173 174 } 174 virtual ~emix() {175 if ( destroyComs ) {176 for ( int i = 0; i < Coms.length(); i++ ) {177 delete Coms ( i );178 }179 }180 }181 //! Auxiliary function for taking ownership of the Coms()182 void ownComs() {183 destroyComs = true;184 }185 175 186 176 //!access function 187 epdf*_Coms ( int i ) {177 shared_ptr<epdf> _Coms ( int i ) { 188 178 return Coms ( i ); 189 179 } 180 190 181 void set_rv ( const RV &rv ) { 191 182 epdf::set_rv ( rv ); … … 233 224 double lognc () const { 234 225 return 0; 235 }; 236 emix* marginal ( const RV &rv ) const; 226 } 227 228 shared_ptr<epdf> marginal ( const RV &rv ) const; 229 void marginal ( const RV &rv, emix &target ) const; 237 230 238 231 //Access methods -
library/bdm/stat/exp_family.h
r488 r504 99 99 }; 100 100 101 template<class sq_T, template <typename> class TEpdf 101 template<class sq_T, template <typename> class TEpdf> 102 102 class mlnorm; 103 103 … … 142 142 vec variance() const {return diag (R.to_mat());} 143 143 // mlnorm<sq_T>* condition ( const RV &rvn ) const ; <=========== fails to cmpile. Why? 144 mpdf* condition (const RV &rvn) const ; 145 enorm<sq_T>* marginal (const RV &rv) const; 146 // epdf* marginal ( const RV &rv ) const; 144 shared_ptr<mpdf> condition ( const RV &rvn ) const; 145 146 // target not typed to mlnorm<sq_T, enorm<sq_T> > & 147 // because that doesn't compile (perhaps because we 148 // haven't finished defining enorm yet), but the type 149 // is required 150 void condition ( const RV &rvn, mpdf &target ) const; 151 152 shared_ptr<epdf> marginal (const RV &rvn ) const; 153 void marginal ( const RV &rvn, enorm<sq_T> &target ) const; 147 154 //!@} 148 155 … … 1235 1242 1236 1243 template<class sq_T> 1237 enorm<sq_T>* enorm<sq_T>::marginal (const RV &rvn) const 1244 shared_ptr<epdf> enorm<sq_T>::marginal ( const RV &rvn ) const 1245 { 1246 enorm<sq_T> *tmp = new enorm<sq_T> (); 1247 shared_ptr<epdf> narrow(tmp); 1248 marginal ( rvn, *tmp ); 1249 return narrow; 1250 } 1251 1252 template<class sq_T> 1253 void enorm<sq_T>::marginal ( const RV &rvn, enorm<sq_T> &target ) const 1238 1254 { 1239 1255 it_assert_debug (isnamed(), "rv description is not assigned"); 1240 1256 ivec irvn = rvn.dataind (rv); 1241 1257 1242 sq_T Rn (R, irvn); //select rows and columns of R 1243 1244 enorm<sq_T>* tmp = new enorm<sq_T>; 1245 tmp->set_rv (rvn); 1246 tmp->set_parameters (mu (irvn), Rn); 1247 return tmp; 1258 sq_T Rn (R, irvn); // select rows and columns of R 1259 1260 target.set_rv ( rvn ); 1261 target.set_parameters (mu (irvn), Rn); 1248 1262 } 1249 1263 1250 1264 template<class sq_T> 1251 mpdf* enorm<sq_T>::condition (const RV &rvn) const 1252 { 1265 shared_ptr<mpdf> enorm<sq_T>::condition ( const RV &rvn ) const 1266 { 1267 mlnorm<sq_T> *tmp = new mlnorm<sq_T> (); 1268 shared_ptr<mpdf> narrow(tmp); 1269 condition ( rvn, *tmp ); 1270 return narrow; 1271 } 1272 1273 template<class sq_T> 1274 void enorm<sq_T>::condition ( const RV &rvn, mpdf &target ) const 1275 { 1276 typedef mlnorm<sq_T> TMlnorm; 1253 1277 1254 1278 it_assert_debug (isnamed(), "rvs are not assigned"); 1279 TMlnorm &uptarget = dynamic_cast<TMlnorm &>(target); 1255 1280 1256 1281 RV rvc = rv.subt (rvn); … … 1276 1301 sq_T R_n (S11 - A *S12.T()); 1277 1302 1278 mlnorm<sq_T>* tmp = new mlnorm<sq_T> (); 1279 tmp->set_rv (rvn); tmp->set_rvc (rvc); 1280 tmp->set_parameters (A, mu1 - A*mu2, R_n); 1281 return tmp; 1303 uptarget.set_rv (rvn); 1304 uptarget.set_rvc (rvc); 1305 uptarget.set_parameters (A, mu1 - A*mu2, R_n); 1282 1306 } 1283 1307 -
library/bdm/stat/merger.cpp
r487 r504 157 157 if ( mpdfs ( i )->dimensionc() > 0 ) { 158 158 // Make marginal on rvc_i 159 epdf*tmp_marg = Mpred->marginal ( mpdfs ( i )->_rvc() );159 shared_ptr<epdf> tmp_marg = Mpred->marginal ( mpdfs ( i )->_rvc() ); 160 160 //compute vector of lw_src 161 161 for ( int k = 0; k < Npoints; k++ ) { … … 163 163 lw_src ( k ) += tmp_marg->evallog ( dls ( i )->get_cond ( Smp ( k ) ) ); 164 164 } 165 delete tmp_marg;166 165 167 166 // sprintf ( str,"marg%d",niter ); … … 173 172 /////////////// 174 173 // There are variales unknown to mpdfs(i) : rvzs 175 mpdf*tmp_cond = Mpred->condition ( rvzs ( i ) );174 shared_ptr<mpdf> tmp_cond = Mpred->condition ( rvzs ( i ) ); 176 175 // Compute likelihood 177 176 vec lw_dbg = lw_src; … … 186 185 } 187 186 } 188 delete tmp_cond;189 187 } 190 188 // Compute likelihood of the partial source -
library/tests/emix_test.cpp
r501 r504 15 15 RV xy = concat ( x, y ); 16 16 17 enorm<ldmat> E1; 18 E1.set_rv ( xy ); 17 shared_ptr<enorm<ldmat> > E1 = new enorm<ldmat>(); 18 E1->set_rv ( xy ); 19 E1->set_parameters ( "1.00054 1.0455" , mat ( "0.740142 -0.259015; -0.259015 1.0302" ) ); 19 20 20 E1.set_parameters ( "1.00054 1.0455" , mat ( "0.740142 -0.259015; -0.259015 1.0302" ) ); 21 enorm<ldmat> E2; 22 E2.set_rv ( xy ); 23 E2.set_parameters ( "-1.2 -0.1" , mat ( "1 0.4; 0.4 0.5" ) ); 21 shared_ptr<enorm<ldmat> > E2 = new enorm<ldmat>(); 22 E2->set_rv ( xy ); 23 E2->set_parameters ( "-1.2 -0.1" , mat ( "1 0.4; 0.4 0.5" ) ); 24 24 25 Array< epdf*> A1 ( 1 );26 A1 ( 0 ) = &E1;25 Array<shared_ptr<epdf> > A1 ( 1 ); 26 A1 ( 0 ) = E1; 27 27 28 28 emix M1; 29 29 M1.set_rv ( xy ); 30 M1.set_parameters ( vec ( "1" ), A1 , false);30 M1.set_parameters ( vec ( "1" ), A1 ); 31 31 32 32 // test if ARX and emix with one ARX are the same 33 epdf*Mm = M1.marginal ( y );34 epdf* Am = E1.marginal ( y );35 mpdf*Mc = M1.condition ( y );36 mpdf* Ac = E1.condition ( y );33 shared_ptr<epdf> Mm = M1.marginal ( y ); 34 shared_ptr<epdf> Am = E1->marginal ( y ); 35 shared_ptr<mpdf> Mc = M1.condition ( y ); 36 shared_ptr<mpdf> Ac = E1->condition ( y ); 37 37 38 mlnorm<ldmat> *wacnd = dynamic_cast<mlnorm<ldmat> *>( Ac);38 mlnorm<ldmat> *wacnd = dynamic_cast<mlnorm<ldmat> *>( Ac.get() ); 39 39 CHECK(wacnd); 40 40 if ( wacnd ) { … … 51 51 52 52 // mixture with two components 53 Array< epdf*> A2 ( 2 );54 A2 ( 0 ) = &E1;55 A2 ( 1 ) = &E2;53 Array<shared_ptr<epdf> > A2 ( 2 ); 54 A2 ( 0 ) = E1; 55 A2 ( 1 ) = E2; 56 56 57 57 emix M2; 58 58 M2.set_rv ( xy ); 59 M2.set_parameters ( vec ( "1" ), A2 , false);59 M2.set_parameters ( vec ( "1" ), A2 ); 60 60 61 61 … … 74 74 CHECK_CLOSE ( mat ( "0.740142 -0.259015; -0.259015 1.0302" ), Er, 2.0 ); 75 75 76 epdf *nm2mrg = M2.marginal ( y ); 77 CHECK ( nm2mrg ); 78 shared_ptr<epdf> Mg ( nm2mrg ); 79 mpdf *Cn = M2.condition ( x ); 80 CHECK ( Cn ); 81 82 #if false 83 it_file it ( "emix_test.it" ); 84 it << Name ( "Smp" ) << Smp; 85 #endif 76 shared_ptr<epdf> Mg = M2.marginal ( y ); 77 CHECK ( Mg.get() ); 78 shared_ptr<mpdf> Cn = M2.condition ( x ); 79 CHECK ( Cn.get() ); 86 80 87 81 // marginal mean 88 82 CHECK_CLOSE ( vec ( "1.0" ), Mg->mean(), 0.1 ); 89 90 #if false91 // putting them back together92 mepdf mMg ( Mg );93 Array<mpdf*> AA ( 2 );94 AA ( 0 ) = Cn;95 AA ( 1 ) = &mMg;96 mprod mEp ( AA );97 98 for ( int j = 0; j < N; j++ ) {99 ll2 ( j ) = mEp.evallogcond ( Smp.get_col ( j ), vec ( 0 ) );100 }101 it << Name ( "ll" ) << ll;102 it << Name ( "ll2" ) << ll2;103 #endif104 83 } -
library/tests/merger_2d_test.cpp
r477 r504 70 70 it << Name ( "S1" ) << f1.evallog_m ( Grid ); 71 71 it << Name ( "S2" ) << f2.evallog_m ( Grid ); 72 cout << ( ( enorm<ldmat>* ) ( MP->_Coms ( 0 ) ) )->_R().to_mat() << endl;72 cout << ( ( enorm<ldmat>* ) ( MP->_Coms ( 0 ).get() ) )->_R().to_mat() << endl; 73 73 } -
library/tests/mixtures_test.cpp
r477 r504 53 53 fsqmat V2 ( mat ( "2 -0.1; -0.1 2" ) ); 54 54 55 enorm<fsqmat> C1;56 C1 .set_rv ( x );57 C1 .set_parameters ( m1, V1 );58 enorm<fsqmat> C2;59 C2 .set_rv ( x );60 C2 .set_parameters ( m2, V2 );55 shared_ptr<enorm<fsqmat> > C1 = new enorm<fsqmat>(); 56 C1->set_rv ( x ); 57 C1->set_parameters ( m1, V1 ); 58 shared_ptr<enorm<fsqmat> > C2 = new enorm<fsqmat>(); 59 C2->set_rv ( x ); 60 C2->set_parameters ( m2, V2 ); 61 61 62 Array< epdf*> Sim ( 2 );63 Sim ( 0 ) = &C1;64 Sim ( 1 ) = &C2;62 Array<shared_ptr<epdf> > Sim ( 2 ); 63 Sim ( 0 ) = C1; 64 Sim ( 1 ) = C2; 65 65 emix Simul; 66 66 Simul.set_rv ( x ); 67 Simul.set_parameters ( "0.5 0.6", Sim , false);67 Simul.set_parameters ( "0.5 0.6", Sim ); 68 68 69 69 // Sample parameters -
library/tests/testSmp.cpp
r488 r504 32 32 33 33 cout << "====== ENorm ====== " << endl; 34 enorm<ldmat> eN;35 eN .set_parameters ( mu0, R );36 mat Smp = eN .sample_m ( N );34 shared_ptr<enorm<ldmat> > eN = new enorm<ldmat>(); 35 eN->set_parameters ( mu0, R ); 36 mat Smp = eN->sample_m ( N ); 37 37 38 38 disp ( mu0, R.to_mat(), Smp ); … … 49 49 vec a = "100000,10000"; 50 50 vec b = a / 10.0; 51 egamma eG;52 eG .set_parameters ( a, b );51 shared_ptr<egamma> eG = new egamma(); 52 eG->set_parameters ( a, b ); 53 53 54 cout << eG .evallog ( a ) << endl;55 Smp = eG .sample_m ( N );54 cout << eG->evallog ( a ) << endl; 55 Smp = eG->sample_m ( N ); 56 56 57 57 vec g_mu = elem_div ( a, b ); … … 60 60 61 61 cout << "====== MGamma ====== " << endl; 62 mgamma mG;62 shared_ptr<mgamma> mG = new mgamma(); 63 63 double k = 10.0; 64 mG .set_parameters ( k, mu0 );64 mG->set_parameters ( k, mu0 ); 65 65 66 Smp = mG .samplecond_m ( mu0, N );66 Smp = mG->samplecond_m ( mu0, N ); 67 67 disp ( mu0, pow ( mu0, 2.0 ) / k, Smp ); 68 68 69 69 cout << "======= EMix ======== " << endl; 70 emix eMix;71 Array< epdf*> Coms ( 2 );72 Coms ( 0 ) = &eG;73 Coms ( 1 ) = &eN;70 shared_ptr<emix> eMix = new emix(); 71 Array<shared_ptr<epdf> > Coms ( 2 ); 72 Coms ( 0 ) = eG; 73 Coms ( 1 ) = eN; 74 74 75 eMix .set_parameters ( vec_2 ( 0.5, 0.5 ), Coms );76 vec smp = eMix .sample();77 Smp = eMix .sample_m ( N );78 disp ( eMix .mean(), zeros ( 2 ), Smp );75 eMix->set_parameters ( vec_2 ( 0.5, 0.5 ), Coms ); 76 vec smp = eMix->sample(); 77 Smp = eMix->sample_m ( N ); 78 disp ( eMix->mean(), zeros ( 2 ), Smp ); 79 79 80 80 cout << "======= MEpdf ======== " << endl; 81 mepdf meMix ( &eMix );81 mepdf meMix ( eMix ); 82 82 83 83 Smp = meMix.samplecond_m ( mu0, N ); 84 disp ( eMix .mean(), zeros ( 2 ), Smp );84 disp ( eMix->mean(), zeros ( 2 ), Smp ); 85 85 86 86 cout << "======= MMix ======== " << endl; 87 87 mmix mMix; 88 88 Array<shared_ptr<mpdf> > mComs ( 2 ); 89 mComs ( 0 ) = &mG; 90 eN.set_mu ( vec_2 ( 0.0, 0.0 ) ); 91 mepdf mEnorm ( &eN ); 92 mComs ( 1 ) = &mEnorm; 89 90 // emix::set_parameters requires the first mpdf to be named 91 mG->set_rv(x); 92 mG->set_rvc(y); 93 mComs ( 0 ) = mG; 94 95 eN->set_mu ( vec_2 ( 0.0, 0.0 ) ); 96 shared_ptr<mepdf> mEnorm = new mepdf ( eN ); 97 mComs ( 1 ) = mEnorm; 93 98 mMix.set_parameters ( vec_2 ( 0.5, 0.5 ), mComs ); 94 99 95 100 Smp = mMix.samplecond_m ( mu0, N ); 96 disp ( 0.5 *eN.mean()+0.4*eG.mean(), zeros ( 2 ), Smp );101 disp ( 0.5 * eN->mean() + 0.4 * eG->mean(), zeros ( 2 ), Smp ); 97 102 98 103 cout << "======= EProd ======== " << endl; 99 // we have to change eG .rv to y100 eN .set_rv ( x );101 eG .set_rv ( y );104 // we have to change eG->rv to y 105 eN->set_rv ( x ); 106 eG->set_rv ( y ); 102 107 //create array 103 108 Array<mpdf*> A ( 2 ); 104 mepdf meN ( &eN);105 mepdf meG ( &eG);109 mepdf meN ( eN.get() ); 110 mepdf meG ( eG.get() ); 106 111 A ( 0 ) = &meN; 107 112 A ( 1 ) = &meG; … … 114 119 vec v0 = vec ( 0 ); 115 120 Smp = eP.samplecond ( v0, N ); 116 disp ( concat ( eN .mean(), eG.mean() ), epV, Smp );121 disp ( concat ( eN->mean(), eG->mean() ), epV, Smp ); 117 122 118 123 cout << "======= eWishart ======== " << endl;