13.3.4. Macro “samplingQMC.C

13.3.4.1. Objective

Generate a design-of-experiments of 100 patterns using quasi Monte-Carlo methods (“Halton” or “Sobol”) with 12 random attributes, following an uniform law on [3.,2.]. All these information are introduced by variables which will be used by the rest of the macro.

13.3.4.2. Macro Uranie

    // Create a TDataServer
    TDataServer * tds = new TDataServer();

    // Parameters
    Int_t nSampler = 100;
    TString sQMC ="halton";     // halton / sobol
    Int_t nVar = 12;

    // Fill the DataServer with the nVar attributes of the study
    for (Int_t ivar=0; ivar<nVar; ivar++)
        tds->addAttribute( new TUniformDistribution(Form("x%d", ivar+1), -3.0, 2.0));

    // Generate the quasi Monte-Carlo sequence from the TDataServer
    TQMC * qmc = new TQMC(tds, sQMC, nSampler);
    qmc->generateSample();

    // Visualisation
    TCanvas  *Canvas = new TCanvas("c1", "Graph for the Macro qmc",5,64,1270,667);
    Canvas->Range(0,0,25,18);

    TPaveLabel *pl = new TPaveLabel(1,16.3,24,17.5, Form("qMC sequence : %s", sQMC.Data()),"br");
    pl->SetBorderSize(0);
    pl->Draw();

    TPad *pad1 = new TPad("pad1", "Determ", 0.02,0.05,0.48,0.88);
    TPad *pad2 = new TPad("pad2","Stoch",0.52,0.05,0.98,0.88);
    pad1->Draw();
    pad2->Draw();

    pad1->cd(); tds->drawTufte("x2:x1");
    pad2->cd(); tds->drawTufte("x11:x12");

Laws are set for each attribute and linked to a TDataServer:

    for (Int_t ivar=0; ivar<nVar; ivar++)
        tds->addAttribute( new TUniformDistribution(Form("x%d", ivar+1), -3.0, 2.0));

The sampling is generated with the QMC method and a correlation is set between the two first attributes:

    TString sQMC ="halton";     // halton / sobol
    TQMC * qmc = new TQMC(tds, sQMC, nSampler);
    qmc->generateSample();

The rest of the code is used to produce a plot.

13.3.4.3. Graph

../../_images/samplingQMC.png

Figure 13.12 Graph of the macro “samplingQMC.C”