13.3.5. Macro “samplingBasicSampling.C”
13.3.5.1. Objective
The objective is to perform three basic samplings, the first with 10000 variables on 10 patterns using a SRS method, the second with 10000 variables on 10 patterns with a LHS method and the third with 10000 variables on 5000 patterns with a SRS method. Each sampling is related to a specific function, and these three functions are run in a fourth one.
13.3.5.2. Macro Uranie
void test_big_sampling(Bool_t bsave = kFALSE)
{
TDataServer *tds = new TDataServer();
cout << " - Creating attributes..." << endl;
for(Int_t i = 0; i < 4000; i++)
tds->addAttribute(new TUniformDistribution(Form("x_%d",i), 0.0, 1.0));
TBasicSampling *s = new TBasicSampling(tds, "srs", 5000);
cout << " - Starting sampling..." << endl;
s->generateSample();
if ( bsave ) {
// WARNING: The generated file is quite big (~300 Mo)
cout << " - Saving data..." << endl;
tds->exportData("_sampling_basic_sampling_big_sampling_.dat");
} else {
cout << " - No saving data (bsave = kFALSE); and the generated file is quite big (~300 Mo)." << endl;
}
}
void test_small_srs_sampling(Bool_t bsave = kFALSE)
{
TDataServer *tds = new TDataServer();
cout << " - Creating attributes..." << endl;
for(Int_t i = 0; i < 10000; i++)
tds->addAttribute(new TUniformDistribution(Form("x_%d",i), 0.0, 1.0));
TBasicSampling *s = new TBasicSampling(tds, "srs", 10);
cout << " - Starting sampling..." << endl;
s->generateSample();
if ( bsave ) {
cout << " - Saving data..." << endl;
tds->exportData("_sampling_basic_sampling_small_srs_sampling_.dat");
} else
cout << " - No saving data (bsave = kFALSE)." << endl;
}
void test_small_lhs_sampling(Bool_t bsave = kFALSE)
{
TDataServer *tds = new TDataServer();
cout << " - Creating attributes..." << endl;
for(Int_t i = 0; i < 10000; i++)
tds->addAttribute(new TUniformDistribution(Form("x_%d",i), 0.0, 1.0));
TBasicSampling *s = new TBasicSampling(tds, "lhs", 10);
cout << " - Starting sampling..." << endl;
s->generateSample();
if ( bsave ) {
cout << " - Saving data..." << endl;
tds->exportData("_sampling_basic_sampling_small_lhs_sampling_.dat");
} else
cout << " - No saving data (bsave = kFALSE)." << endl;
}
void samplingBasicSampling(const string& file_name="")
{
cout << endl << "***************************************************" << endl;
cout << " ** Test small SRS sampling (10000 attributes, 10 data)" << endl;
test_small_srs_sampling(kTRUE);
cout << "***************************************************" << endl;
gROOT->ls();
cout << endl << "***************************************************" << endl;
cout << " ** Test small LHS sampling (10000 attributes, 10 data)" << endl;
test_small_lhs_sampling(kTRUE);
cout << "***************************************************" << endl;
gROOT->ls();
cout << endl << "***************************************************" << endl;
cout << " ** Test big sampling (4000 attributes, 5000 data)" << endl;
test_big_sampling();
cout << "***************************************************" << endl;
gROOT->ls();
}