Example showing confidence intervals with four techniques.
An example that shows confidence intervals with four techniques. The model is a Normal Gaussian G(x|mu,sigma) with 100 samples of x. The answer is known analytically, so this is a good example to validate the RooStats tools.
- expected interval is [-0.162917, 0.229075]
- plc interval is [-0.162917, 0.229075]
- fc interval is [-0.17 , 0.23] // stepsize is 0.01
- bc interval is [-0.162918, 0.229076]
- mcmc interval is [-0.166999, 0.230224]
Processing /mnt/build/workspace/root-makedoc-v608/rootspi/rdoc/src/v6-08-00-patches/tutorials/roostats/IntervalExamples.C...
#include <iostream>
void IntervalExamples()
{
wspace->
factory(
"Gaussian::normal(x[-10,10],mu[-1,1],sigma[1])");
modelConfig->
SetPdf( *wspace->
pdf(
"normal") );
double confidenceLevel = 0.95;
plc.SetConfidenceLevel( confidenceLevel);
fc.SetConfidenceLevel( confidenceLevel);
fc.SetNBins(100);
fc.UseAdaptiveSampling(true);
fc.FluctuateNumDataEntries(false);
wspace->
factory(
"Uniform::prior(mu)");
bc.SetConfidenceLevel( confidenceLevel);
mc.SetConfidenceLevel( confidenceLevel);
mc.SetNumBins(200);
mc.SetNumBurnInSteps(500);
mc.SetNumIters(100000);
mc.SetLeftSideTailFraction(0.5);
double expectedLL = data->
mean(*x)
double expectedUL = data->
mean(*x)
std::cout << "expected interval is [" <<
expectedLL << ", " <<
expectedUL << "]" << endl;
cout << "plc interval is [" <<
std::cout << "fc interval is ["<<
cout << "bc interval is [" <<
cout << "mc interval is [" <<
cout << "is mu=0 in the interval? " <<
plot.Draw();
RooPlot * bcPlot = bc.GetPosteriorPlot();
}
- Author
- Kyle Cranmer
Definition in file IntervalExamples.C.