Commit 217869ae authored by Plaszczynski Stephane's avatar Plaszczynski Stephane
Browse files

better seed generation

parent 1b7ffecc
......@@ -26,8 +26,9 @@
#include <fstream>
#include <vector>
#include <ctime>
#include <stdint.h>
//#include <ctime>
#include <sys/time.h>
#include <cstdlib>
using namespace std;
......@@ -74,21 +75,23 @@ int main(int argc, char *argv[])
//--------defining seeds-----------------------------------------------
unsigned int seed(0);
if (parser.params.param_present("seed")){
seed=parser.params.find<int>("seed",1234);
seed=parser.params.find<int>("seed",0);
}
else {//pick automatiocally
time_t result = time(NULL);
seed=static_cast<uint32_t>(result);
else {//pick automatiocally: microseconds from current time
timeval CurrentTime;
gettimeofday( &CurrentTime, NULL );
seed=static_cast<unsigned int>(CurrentTime.tv_usec);
}
cout << "seed for proposal=" << seed << endl;
unsigned int seedU(0);
//need anothe rone for the algorithm itsel
//need another one for the algorithm itsel
if (parser.params.param_present("seedU")){
seedU=parser.params.find<int>("seedU",1234);
seedU=parser.params.find<int>("seedU",0);
}
else {//automatically
seedU=seed%1024;
else {//throw a random number to avoid correlations
std::srand(seed);
seedU=static_cast<unsigned int>(std::rand()%32768);
}
cout << "seed for algorithm=" << seedU << endl;
......@@ -175,7 +178,6 @@ int main(int argc, char *argv[])
cout << "cov domove= " <<move->Get_cov_matrix() << endl;
if(use_ext_cov==true){ move->Set_cov_matrix(proposal->Get_cov_matrix());}
HepVector start(dim);
sleep(1);
move->init_generator(time(NULL));
move->Set_scale(scale);
cout << "start=" << start << endl;
......
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