[RooStats] ToyMCSampler returns strange values

Dear all, I want to sample the distribution of a profiled likelihood ratio. I’m able to compute one value:

    ProfileLikelihoodTestStat test(*ws.pdf("model"));
    test.SetOneSided();
    RooArgSet* poi_set = new RooArgSet(*ws->set("poi"));
    double roostats_result = test.Evaluate(*data, *poi_set);

this works and gives resonable value (0.75). Now I want to use ToyMCSampler:

    const int total_exp = 2;
    ToyMCSampler sampler(test, total_exp);
    sampler.SetObservables(*ws->set("obs"));
    sampler.SetParametersForTestStat(*poi_set);
    sampler.SetPdf(*ws->pdf("model"));
    sampler.SetSamplingDistName("q_1 given #mu=1");
    SamplingDistribution* sampling_dist = sampler.GetSamplingDistribution(*poi_set);

    vector<Double_t> ss = sampling_dist->GetSamplingDistribution();
    for (unsigned int i=0; i!=ss.size(); ++i, cout << i << ": " << ss[i] << endl);

it returns

1: 0
2: 1.58101e-322

Where is the error?

Hi,

The error is in your code:

for (unsigned int i=0; i!=ss.size(); ++i, cout << i << ": " << ss[i] << endl);

should be :

for (unsigned int i=0; i!=ss.size(); ++i) 
    cout << i << ": " << ss[i] << endl;

[quote=“moneta”]Hi,

The error is in your code:

for (unsigned int i=0; i!=ss.size(); ++i, cout << i << ": " << ss[i] << endl);

should be :

for (unsigned int i=0; i!=ss.size(); ++i) cout << i << ": " << ss[i] << endl; [/quote]

I’m really really sorry, please forgive me… I wanted to use a compact form and I wrote it in the wrong order.