Changeset 310
- Timestamp:
- 04/09/09 14:33:08 (16 years ago)
- Files:
-
- 1 added
- 5 modified
Legend:
- Unmodified
- Added
- Removed
-
bdm/estim/merger.cpp
r301 r310 88 88 89 89 // This will be active only later in iterations!!! 90 if ( ( !fix_smp ) & ( 1./sum_sqr ( w ) < 0.9*Ns ) )90 if ( ( !fix_smp ) & ( 1./sum_sqr ( w ) <effss_coef*Ns ) ) 91 91 { 92 92 // Generate new samples … … 98 98 set_col_part ( Smp_ex,i,Smp ( i ) ); 99 99 //Importance of the mixture 100 lw_mix ( i ) =Mix.logpred (Smp_ex.get_col(i) ); 100 //lw_mix ( i ) =Mix.logpred (Smp_ex.get_col(i) ); 101 lw_mix ( i ) = Mpred->evallog(Smp(i)); 101 102 } 102 103 if ( 1 ) 103 104 { 104 105 cout<<"Resampling =" << 1./sum_sqr ( w ) << endl; 106 cout << Mix._e()->mean() <<endl; 105 107 cout << sum ( Smp_ex,2 ) /Ns <<endl; 106 108 cout << Smp_ex*Smp_ex.T() /Ns << endl; … … 111 113 sprintf ( str,"Mpred_mean%d",niter ); 112 114 *dbg << Name ( str ) << Mpred->mean(); 115 sprintf ( str,"Mpred_var%d",niter ); 116 *dbg << Name ( str ) << Mpred->variance(); 113 117 114 118 … … 216 220 // ==== stopping rule === 217 221 niter++; 218 converged = ( niter> 20 );222 converged = ( niter>40 ); 219 223 } 220 224 delete Mpred; -
bdm/estim/merger.h
r299 r310 47 47 //! Projection to empirical density 48 48 eEmp eSmp; 49 //! coefficient of resampling 50 double effss_coef; 49 51 50 52 //! debug or not debug … … 88 90 void debug_file ( const string fname ) { if ( DBG ) delete dbg; dbg = new it_file ( fname ); if ( dbg ) DBG=true;} 89 91 //! Set internal parameters used in approximation 90 void set_parameters ( double beta0, int Ns0, int Nc0 ) {beta=beta0;Ns=Ns0;Nc=Nc0;eSmp.set_parameters ( Ns0,false );} 92 void set_parameters ( double beta0, int Ns0, int Nc0, double effss_coef0=0.5 ) {beta=beta0; 93 Ns=Ns0; 94 Nc=Nc0; 95 effss_coef=effss_coef0; 96 eSmp.set_parameters ( Ns0,false ); 97 } 91 98 void set_grid ( Array<vec> &XYZ ) 92 99 { -
bdm/stat/emix.h
r286 r310 112 112 //non-central moment 113 113 vec mom2 = zeros ( dim ); 114 for ( int i = 0;i < w.length();i++ ) {mom2 += w ( i ) * pow ( Coms ( i )->mean(),2); }114 for ( int i = 0;i < w.length();i++ ) {mom2 += w ( i ) * (Coms(i)->variance() + pow ( Coms ( i )->mean(),2 )); } 115 115 //central moment 116 116 return mom2-pow ( mean(),2 ); -
bdm/stat/libEF.h
r299 r310 230 230 //!sufficient statistics 231 231 vec beta; 232 //!speedup variable233 double gamma;234 232 public: 235 233 //!\name Constructors … … 243 241 beta= beta0; 244 242 dim = beta.length(); 245 gamma = sum ( beta );246 243 } 247 244 //!@} 248 245 249 246 vec sample() const {it_error ( "Not implemented" );return vec_1 ( 0.0 );}; 250 vec mean() const {return beta/ gamma;};251 vec variance() const { return elem_mult ( beta, ( beta+1 ) ) / ( gamma* ( gamma+1 ) );}247 vec mean() const {return beta/sum(beta);}; 248 vec variance() const {double gamma =sum(beta); return elem_mult ( beta, ( beta+1 ) ) / ( gamma* ( gamma+1 ) );} 252 249 //! In this instance, val is ... 253 250 double evallog_nn ( const vec &val ) const -
mpdm/TR2244/merger_iter_cond.cpp
r301 r310 25 25 26 26 //Differneces in constant term are essential 27 f1.set_parameters ( " 0.4","1",mat ( "0.04" ) );28 f2.set_parameters ( " 0.2", mat ( "0.08" ) );27 f1.set_parameters ( "1","1",mat ( "0.01" ) ); 28 f2.set_parameters ( "2", mat ( "0.02" ) ); 29 29 30 30 mepdf mf2(&f2); … … 40 40 /* Cov(1,2)=0.29; 41 41 Cov(2,1)=0.29;*/ 42 g0.set_parameters ( vec ( " 0 0" ),Cov);// +1*ones ( 3,3 ) );42 g0.set_parameters ( vec ( "2 1" ),Cov);// +1*ones ( 3,3 ) ); 43 43 44 44 // enorm<ldmat>* teste=g0.marginal(concat(u1,u2)); 45 45 // mlnorm<ldmat>* testm=(mlnorm<ldmat>*)teste->condition(u2); 46 46 47 M.set_parameters ( 1.2,1000,1 );47 M.set_parameters ( 1.2,1000,1,0.5); 48 48 49 49 Array<vec> YUU(2); 50 YUU(0)=linspace(-2.9,3.1,20); 51 YUU(1)=linspace(-5,5,20); 52 //YUU(2)=linspace(-3,3,20); 50 YUU(0)=linspace(1.5,2.5,20); 51 YUU(1)=linspace(0.5,1.5,20); 52 53 YUU(0)=linspace(0,4,20); 54 YUU(1)=linspace(-1,3,20); 55 //YUU(2)=linspace(-3,3,20); 53 56 54 M.set_grid(YUU);57 //M.set_grid(YUU); 55 58 56 59 int Ntrials=1; … … 68 71 epdf* MP = MM._Coms ( 0 )->epredictor ( ); 69 72 MP->set_rv(all); 73 74 //Missing piece 75 enorm<ldmat>* miss= (enorm<ldmat>*) MP->marginal(u1); 76 cout << "Missing: " << miss->_mu() << " +- " << miss->_R().to_mat() << endl; 70 77 71 78 RV yu1 = y; yu1.add ( u1 ); … … 102 109 cout << "R1: " << R1mean << " +- " << 2*sqrt(sum_sqr(R1s)/Ntrials-R1mean*R1mean) <<endl; 103 110 cout << "R2: " << R2mean << " +- " << 2*sqrt(sum_sqr(R2s)/Ntrials-R2mean*R2mean) <<endl; 111 112 104 113 }