13.3.2. Macro “samplingLHS.C”
13.3.2.1. Objective
Generate a design-of-experiments of 5000 patterns, using the LHS method, with three random attributes:
Attribute x1 obeys an uniform law on interval [3, 4];
Attribute x2 obeys a normal law with mean value equal to 0.5 and standard deviation set to 1.5;
Attribute x3 follows a triangular law on interval [1, 5] with mode 4.
13.3.2.2. Macro Uranie
// Create a TDataServer
TDataServer * tds = new TDataServer();
// Fill the DataServer with the three attributes of the study
tds->addAttribute(new TUniformDistribution("x1", 3., 4.));
tds->addAttribute(new TNormalDistribution("x2", 0.5, 1.5));
tds->addAttribute(new TTriangularDistribution("x3", 1., 5., 4.));
// Generate the sampling from the TDataServer
TSampling *sampling = new TSampling(tds, "lhs", 5000);
sampling->generateSample();
tds->StartViewer();
// Graph
TCanvas *Canvas = new TCanvas("c1", "Graph for the Macro sampling",5,64,1270,667);
TPad *pad = new TPad("pad","pad",0, 0.03, 1, 1); pad->Draw();
pad->Divide(2,2);
pad->cd(1); tds->Draw("x1");
pad->cd(2); tds->Draw("x2");
pad->cd(3); tds->Draw("x3");
pad->cd(4); tds->drawTufte("x1:x2");
Laws are set for each attribute and linked to a TDataServer:
tds->addAttribute(new TUniformDistribution("x1", 3., 4.));
tds->addAttribute(new TNormalDistribution("x2", 0.5, 1.5));
tds->addAttribute(new TTriangularDistribution("x3", 1., 5., 4.));
The sampling is generated with the LHS method!
TSampling *sampling = new TSampling(tds, "lhs", 5000);
sampling->generateSample();
13.3.2.3. Graph
Figure 13.10 Graph of the macro “samplingLHS.C”