13.4.10. Macro “samplingSpaceFilling.py”
13.4.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.4.10.2. Macro Uranie
"""
Example of space filling DoE
"""
from URANIE import DataServer, Sampler
import ROOT
def generate_and_draw_it(l_pad, l_tds, l_tsp, l_nb, l_title):
"""Delete the tuple, generate a sample and draw the plot."""
l_pad.cd(l_nb+1)
l_tds.deleteTuple()
l_tsp.generateSample()
l_tds.drawTufte("x2:x1")
l_pad.GetPad(l_nb+1).GetPrimitive("TPave").SetLabel("")
ROOT.gPad.GetPrimitive("htemp").SetTitle(l_title)
ROOT.gPad.Modified()
# Attributes
att1 = DataServer.TUniformDistribution("x1", 10, 12)
att2 = DataServer.TUniformDistribution("x2", 0, 3)
nor1 = DataServer.TNormalDistribution("x1", 0, 1)
nor2 = DataServer.TNormalDistribution("x2", 3, 5)
# Pointer to DataServer and Samplers
tds = [0., 0., 0.]
tsp = [0., 0., 0., 0., 0., 0., 0., 0., 0.]
algoname = ["SaltelliA", "SaltelliB", "Cukier"]
# Canvas to produce the 3x3 plot
Can = ROOT.TCanvas("Can", "Can", 10, 32, 1200, 1200)
pad = ROOT.TPad("pad", "pad", 0, 0.03, 1, 1)
pad.Draw()
pad.Divide(3, 3)
ct = 0
for itds in range(3):
# Create a DataServer to store new configuration
# (UnivsUni, GausvsUni, Gaus vs Gaus)
tds[itds] = DataServer.TDataServer("test", "test")
if itds == 0:
tds[itds].addAttribute(att1)
tds[itds].addAttribute(att2)
if itds == 1:
tds[itds].addAttribute(att1)
tds[itds].addAttribute(nor2)
if itds == 2:
tds[itds].addAttribute(nor1)
tds[itds].addAttribute(nor2)
# Looping over the 3 spacefilling algo available
for ialg in range(3):
# Instantiate the sampler
if ialg == 0:
tsp[ct] = Sampler.TSpaceFilling(tds[itds], "srs", 1000,
Sampler.TSpaceFilling.kSaltelliA)
if ialg == 1:
tsp[ct] = Sampler.TSpaceFilling(tds[itds], "srs", 1000,
Sampler.TSpaceFilling.kSaltelliB)
if ialg == 2:
tsp[ct] = Sampler.TSpaceFilling(tds[itds], "srs", 1000,
Sampler.TSpaceFilling.kCukier)
# Draw with correct legend
generate_and_draw_it(pad, tds[itds], tsp[ct], ct, algoname[ialg])
ct = ct+1
13.4.10.3. Graph
Figure 13.13 Graph of the macro “samplingSpaceFilling.py”