13.3.10. Macro “samplingSpaceFilling.C”
13.3.10.1. Objective
This macro shows the usage of the TSpaceFilling class and the resulting design-of-experiments in three simple
dataserver cases:
with two uniform distributions
with one uniform and one gaussian distributions
with two gaussian distributions
For each of these configurations (represented in the following plot by a line), the three available algorithms are also tested. They are called:
SaltelliA
SaltelliB
Cukier
This kind of design-of-experiments is not intented to be used regurlarly, it is requested only by few mechanisms like the FAST and RBD methods which rely on fourier transformations. This macro and, above all, the following plot, is made mainly for illustration purpose.
13.3.10.2. Macro Uranie
void GenerateAndDrawIt(TPad* pad, TDataServer *tds, TSpaceFilling *tsp, int nb, const char *title)
{
pad->cd(nb+1);
tds->deleteTuple();
tsp->generateSample();
tds->drawTufte("x2:x1");
((TPaveLabel*)(pad->GetPad(nb+1)->GetPrimitive("TPave")))->SetLabel("");
((TH1F*)gPad->GetPrimitive("htemp"))->SetTitle(title);
gPad->Modified();
}
void samplingSpaceFilling(const string& figure="figure.png", const string& style="")
{
//Attributes
TUniformDistribution *att1 = new TUniformDistribution("x1",10,12);
TUniformDistribution *att2 = new TUniformDistribution("x2",0,3);
TNormalDistribution *nor1 = new TNormalDistribution("x1",0,1);
TNormalDistribution *nor2 = new TNormalDistribution("x2",3,5);
// Pointer to DataServer and Samplers
TDataServer *tds[3];
TSpaceFilling *tsp[9];
string algoname[3]={"SaltelliA","SaltelliB","Cukier"};
// Canvas to produce the 3x3 plot
TCanvas *Can = new TCanvas("Can","Can",10,32,1200,1200);
TPad *pad = new TPad("pad","pad",0, 0.03, 1, 1); pad->Draw();
pad->Divide(3,3);
int counter=0;
for(unsigned int itds=0; itds<3; itds++)
{
// Create a DataServer to store new configuration (UnivsUni, GausvsUni, Gaus vs Gaus)
tds[itds] = new TDataServer("test","test");
switch(itds)
{
case 0: tds[itds]->addAttribute(att1); tds[itds]->addAttribute(att2); break;
case 1: tds[itds]->addAttribute(att1); tds[itds]->addAttribute(nor2); break;
case 2: tds[itds]->addAttribute(nor1); tds[itds]->addAttribute(nor2); break;
}
// Looping over the 3 spacefilling algo available
for(unsigned int ialg=0; ialg<3; ialg++)
{
// Instantiate the sampler
switch(ialg)
{
case 0: tsp[counter] = new TSpaceFilling(tds[itds], "srs", 1000, TSpaceFilling::kSaltelliA); break;
case 1: tsp[counter] = new TSpaceFilling(tds[itds], "srs", 1000, TSpaceFilling::kSaltelliB); break;
case 2: tsp[counter] = new TSpaceFilling(tds[itds], "srs", 1000, TSpaceFilling::kCukier); break;
}
//Draw with correct legend
GenerateAndDrawIt(pad, tds[itds], tsp[counter], counter, algoname[ialg].c_str());
counter++;
}
}
}
13.3.10.3. Graph
Figure 13.13 Graph of the macro “samplingSpaceFilling.C”