Commit 7724a41b authored by Plaszczynski Stephane's avatar Plaszczynski Stephane
Browse files

correct mcm for dim=1 + messages. add accessor to Combiner

parent 61d0b356
......@@ -49,10 +49,11 @@ public:
//is the computation a success
bool success() const {return OK;}
//accessor to engine
Engine* getEngine() {return engine;}
const std::vector<Chi2Data*>& chi2s() const {return obs;}
private:
std::vector<Chi2Data*> obs;
Timer* timer;
......
......@@ -193,6 +193,11 @@ void MCMC_adaptive::fill_chain(pdf* target_func, pdf* proposal,int init_step, co
///////////////////////////////////////main loop////////////////////////
for(int i=2; i<_length; i++)
{
if (i==2)
cout <<">>> Metropolis phase with scale="<< g-> Get_scale() << endl;
if((_verbose==true)&&(i%1000==0))
{
cout << "step=" << i << endl;
......@@ -216,12 +221,15 @@ void MCMC_adaptive::fill_chain(pdf* target_func, pdf* proposal,int init_step, co
//first extimation of covariance to be redone
//cout << "matrix_0="<<g->Get_cov_matrix() << endl;
extract_cov(0,i-1,false);
g->Set_cov_matrix(_extracted_cov);
g->Set_cov_matrix(_extracted_cov);
if (_verbose) cout << "matrix_t0="<<g->Get_cov_matrix() << endl;
flag_shoot=proposal->shoot(jump, true);
if(_dim==1) g->Set_scale(0.1);
else g->Set_scale(2.4*2.4/_dim);
//g->Set_scale(1.0);
//if(_dim==1) g->Set_scale(0.1);
g->Set_scale(2.4*2.4/_dim);
cout << ">>> i="<< _t0 << ": starting cov adapatation with fixed scale=" << g-> Get_scale() <<endl;
}
else //from here starts adaptation process
......@@ -255,13 +263,19 @@ void MCMC_adaptive::fill_chain(pdf* target_func, pdf* proposal,int init_step, co
cout<<"scale="<<scale<<endl;
}
if(i>_t0+_ts)
{
{
if (i==(_t0+_ts+1)){
cout << ">>> i="<< i << ": starting scale adaptation=" << g-> Get_scale() <<endl;
}
double ar=acc_rate(i-100,i);
if((_verbose==true)||(i%1000==0))
{
cout<<"acc rate="<<ar<<endl;
}
g->Set_scale(g->Get_scale()+ (ar-0.25)*gamma_i);
double ar_target=(_dim<=2 ? 0.5 : 0.25);
g->Set_scale(g->Get_scale()+ (ar-ar_target)*gamma_i);
double scale_min=0.001;
if(scale<scale_min) {g->Set_scale(scale_min);}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment