Accept/reject in RooFit

Hi,

apparently it is not possible to generate 4-dimensional distributions using accept/reject in RooFit. When trying I’m getting this warning:

[#0] WARNING:Generation – pdf_AccRej::RooAcceptReject: WARNING: generating 4 variables with accept-reject may not be accurate

What’s the reason for this? Besides performance considerations, I don’t see a reason why acc/rej wouldn’t be accurate in 4 dimensions?

This piece of test code shows what I mean:

[code] RooRealVar x1(“x1”, “x1”, 0, -10, 10);
RooRealVar x2(“x2”, “x2”, 0, -10, 10);
RooRealVar x3(“x3”, “x3”, 0, -10, 10);
RooRealVar x4(“x4”, “x4”, 0, -10, 10);

// will terminate with "Abort" if not restricting bins
x1.setBins(10);
x2.setBins(10);
x3.setBins(10);
x4.setBins(10);

RooArgSet variables(x1, x2, x3, x4);

// read ASCII dataset which contains more than 4 columns
RooMsgService::instance().setGlobalKillBelow(RooMsgService::ERROR);
RooDataSet*  dataset = RooDataSet::read("dat/glwFinalFitter-toy-fdm1.dat", variables, "");
RooMsgService::instance().reset();
dataset->Print("v");

// drop "blindState", otherwise RooHistPdf complains
dataset = new RooDataSet("data_clean", "data_clean", dataset, variables);
dataset->Print("v");

RooDataHist* hist = dataset->binnedClone("hist");
hist->Print("v");

RooHistPdf   pdf ("pdf", "pdf", variables, *hist);

RooDataSet*  toy = pdf.generate(variables, 1000);[/code]

Cheers,

  • Mo

Hi,

It’s not impossible, but (in the most generic case) quite difficult: accept/reject sampling
implies that you know that maximum of the function. If this information is not known
from an analytical source (as is usually the case), one has to estimate the maximum
through repeated sampling at random points in space. As the number of dimensions
increases the probability that you miss a ‘spike’ becomes increasingly likely, in which
case you will not accurately generate the distribution., and the number of trials that must be made has to increased to quite large numbers to avoid this from happening.

If you know your function is very very smooth, this will not be an issue.

A second issue with RooAcceptReject specifically is that if the function is not very
flat its generation efficiency (defined as the integral of the pdf / fMax * volume) can
be horribly low.

This second issue is mitigated in recent RooFit versions (3.00 aka ROOT 5.24) where
the FOAM generator is used instead for such cases.

Wouter

Hi Wouter,

ok, but why wouldn’t I know the maximum of a 4-d histogram? Can’t be that hard to calculate it?

  • Mo

Hi,

A RooHistPdf should have a special handling that will advertise the bin with the largest
content as the ‘analytical’ maximum to the generator context, but I now see why that fails:

//_____________________________________________________________________________
Int_t RooHistPdf::getMaxVal(const RooArgSet& /vars/) const
{
// Not implemented yet
return 0 ;
}

//_____________________________________________________________________________
Double_t RooHistPdf::maxVal(Int_t /code/) const
{
// Not implemented yet
return 0 ;
}

I’ll try to fix that tonight so that that can still go into the ROOT 5.25/02 release of next week.

Wouter

Thanks!

But absolutely no need to do this tonight :slight_smile:

  • Mo

Hi,

A fix has gone into SVN and will appear in ROOT 5.25/02 next week.

Wouter