13.4.2. Macro “samplingLHS.py”
13.4.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.4.2.2. Macro Uranie
"""
Example of LHS DoE sampling
"""
from URANIE import DataServer, Sampler
import ROOT
# Create a DataServer.TDataServer
tds = DataServer.TDataServer()
# Fill the DataServer with the three attributes of the study
tds.addAttribute(DataServer.TUniformDistribution("x1", 3., 4.))
tds.addAttribute(DataServer.TNormalDistribution("x2", 0.5, 1.5))
tds.addAttribute(DataServer.TTriangularDistribution("x3", 1., 5., 4.))
# Generate the sampling from the DataServer.TDataServer
sampling = Sampler.TSampling(tds, "lhs", 5000)
sampling.generateSample()
tds.StartViewer()
# Graph
Canvas = ROOT.TCanvas("c1", "Graph for the Macro sampling", 5, 64, 1270, 667)
pad = ROOT.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(DataServer.TUniformDistribution("x1", 3., 4.))
tds.addAttribute(DataServer.TNormalDistribution("x2", 0.5, 1.5))
tds.addAttribute(DataServer.TTriangularDistribution("x3", 1., 5., 4.))
The sampling is generated with the LHS method!
sampling = Sampler.TSampling(tds, "lhs", 5000)
sampling.generateSample()
13.4.2.3. Graph
Figure 13.10 Graph of the macro “samplingLHS.py”