Commit b708b6f2 authored by Plaszczynski Stephane's avatar Plaszczynski Stephane

some nice features from v3_euclid

parent 4fda1034
...@@ -654,7 +654,6 @@ double ClassEngine::get_Dv(double z) ...@@ -654,7 +654,6 @@ double ClassEngine::get_Dv(double z)
//call to fill pvecback //call to fill pvecback
background_at_tau(&ba,tau,ba.long_info,ba.inter_normal, &index, pvecback); background_at_tau(&ba,tau,ba.long_info,ba.inter_normal, &index, pvecback);
double H_z=pvecback[ba.index_bg_H]; double H_z=pvecback[ba.index_bg_H];
double D_ang=pvecback[ba.index_bg_ang_distance]; double D_ang=pvecback[ba.index_bg_ang_distance];
#ifdef DBUG #ifdef DBUG
...@@ -663,8 +662,7 @@ double ClassEngine::get_Dv(double z) ...@@ -663,8 +662,7 @@ double ClassEngine::get_Dv(double z)
#endif #endif
double D_v; double D_v;
D_v=pow(D_ang*(1+z),2)*z/H_z; D_v=std::pow(D_ang*(1+z)*D_ang*(1+z)*z/H_z,1./3.);
D_v=pow(D_v,1./3.);
#ifdef DBUG #ifdef DBUG
cout << D_v << endl; cout << D_v << endl;
#endif #endif
......
...@@ -38,7 +38,7 @@ public: ...@@ -38,7 +38,7 @@ public:
const std::string& prefile); const std::string& prefile);
// destructor // destructor
~MnClassEngine(); virtual ~MnClassEngine();
//this will update the CLASS computations for a realization of par //this will update the CLASS computations for a realization of par
//conistent with the MnUserVariables //conistent with the MnUserVariables
......
...@@ -35,7 +35,7 @@ public: ...@@ -35,7 +35,7 @@ public:
Chi2Lensing(LensingLikelihood* ll, const Variables& pars,Engine* _klass); Chi2Lensing(LensingLikelihood* ll, const Variables& pars,Engine* _klass);
// destructor // destructor
~Chi2Lensing(); virtual ~Chi2Lensing();
//operator to override: must return something comptible with -2log(L) //operator to override: must return something comptible with -2log(L)
double chi2_eff(const std::vector<double>& par) const; double chi2_eff(const std::vector<double>& par) const;
......
...@@ -323,7 +323,8 @@ void MCMC_adaptive::fill_chain(pdf* target_func, pdf* proposal,int init_step, co ...@@ -323,7 +323,8 @@ void MCMC_adaptive::fill_chain(pdf* target_func, pdf* proposal,int init_step, co
int gate=_bunchSize; int gate=_bunchSize;
if(i%gate==0) if(i%gate==0)
{ {
if (_verbose) cout << "dump at index " << i << " from " << i-gate << " to " << i-1 << endl; //if (_verbose) cout << "dump at index " << i << " from " << i-gate << " to " << i-1 << endl;
cout << i << " written" <<endl;
chain_running.open (chain_run_name, fstream::app); chain_running.open (chain_run_name, fstream::app);
for(int k=i-gate; k<i; k++) for(int k=i-gate; k<i; k++)
......
...@@ -136,7 +136,7 @@ void MCMC_sampler::write_chain(char* str) ...@@ -136,7 +136,7 @@ void MCMC_sampler::write_chain(char* str)
} }
void MCMC_sampler::write_if_useful(vector<double>& vec,char* str) void MCMC_sampler::write_if_useful(vector<double>& vec,const char* str)
{ {
cout << "output written in:"<< str << endl; cout << "output written in:"<< str << endl;
...@@ -149,7 +149,7 @@ void MCMC_sampler::write_if_useful(vector<double>& vec,char* str) ...@@ -149,7 +149,7 @@ void MCMC_sampler::write_if_useful(vector<double>& vec,char* str)
} }
void MCMC_sampler::write_vecHep(vector<HepVector >& vec,char* str) void MCMC_sampler::write_vecHep(vector<HepVector >& vec,const char* str)
{ {
cout << "output written in:"<< str << endl; cout << "output written in:"<< str << endl;
......
...@@ -67,8 +67,8 @@ public: ...@@ -67,8 +67,8 @@ public:
void compute_mean(int stop,HepVector mean); void compute_mean(int stop,HepVector mean);
void write_rearranged_chain(char* str); //rec, value, lkh void write_rearranged_chain(char* str); //rec, value, lkh
void set_par(Parser parser); // set parameters value using Parser void set_par(Parser parser); // set parameters value using Parser
void write_if_useful(std::vector<double>& vec,char* str); void write_if_useful(std::vector<double>& vec,const char* str);
void write_vecHep(std::vector<HepVector >& vec,char* str); void write_vecHep(std::vector<HepVector >& vec,const char* str);
//accessors //accessors
......
...@@ -48,7 +48,12 @@ int main(int argc, char *argv[]) ...@@ -48,7 +48,12 @@ int main(int argc, char *argv[])
std::cout << "output file " + fileName + " already exists: removing it"<<endl; std::cout << "output file " + fileName + " already exists: removing it"<<endl;
remove_file(fileName); remove_file(fileName);
} }
string ar_file=string("ar_vs_length_")+fileName;
string scale_file=string("scale_")+fileName;
string cor_file=string("prop_cov_")+fileName;
cout << "output files:" <<endl;
cout << ar_file << " " << scale_file << " " << cor_file << " " << endl;
//MCMC specific parameters //MCMC specific parameters
const string algo=parser.params.find<string>("algo","ada"); const string algo=parser.params.find<string>("algo","ada");
...@@ -151,8 +156,7 @@ int main(int argc, char *argv[]) ...@@ -151,8 +156,7 @@ int main(int argc, char *argv[])
if(use_ext_cov) if(use_ext_cov)
{ {
cout << "Read proposal cov matrix.." << endl; cout << "Read proposal cov matrix=" << proposal_cov.c_str() << endl;
cout << proposal_cov.c_str() << endl;
proposal->set_cov(proposal_cov.c_str()); proposal->set_cov(proposal_cov.c_str());
} }
else { else {
...@@ -245,21 +249,21 @@ int main(int argc, char *argv[]) ...@@ -245,21 +249,21 @@ int main(int argc, char *argv[])
{ar_vs_length.push_back(chain->acc_rate(0,step));} {ar_vs_length.push_back(chain->acc_rate(0,step));}
} }
chain->write_if_useful(ar_vs_length,"ar_vs_length.txt"); chain->write_if_useful(ar_vs_length,ar_file.c_str());
if(algo=="ada") if(algo=="ada")
{ {
MCMC_adaptive* ada=dynamic_cast<MCMC_adaptive*>(chain); MCMC_adaptive* ada=dynamic_cast<MCMC_adaptive*>(chain);
chain->write_if_useful(proposal->_scale_vs_length,"scale_vs_length.txt"); chain->write_if_useful(proposal->_scale_vs_length,scale_file.c_str());
ofstream f("corr.txt"); ofstream f(cor_file.c_str());
if(!f) { if(!f) {
cout << "Error in file creation!"; cout << "Error in file creation!";
} }
f << ada->mean() << endl //mean f << ada->mean() << endl //mean
<< proposal->Get_cov_matrix() << endl; //cov matrix << proposal->Get_cov_matrix() << endl; //cov matrix
f.close(); f.close();
cout<<"output written in:corr.txt"<<endl;; cout<<"proposal cov written in " << cor_file <<endl;;
} }
delete chi2; delete chi2;
......
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