Skip to content

[RF] FrequentistCalculator cannot handle non-parametric Pdfs #19419

@cburgard

Description

@cburgard

Check duplicate issues.

  • Checked for duplicates

Description

When trying to use the FrequentistCalculator to conduct a hypothesis test on non-parametric Pdfs, a segfault is encountered.

MWE is attached.

Reproducer

import ROOT

# Observable
x = ROOT.RooRealVar("x", "x", 0, 20)
x.setBins(40)

# Create two underlying shapes for H0 and H1
gauss_H0 = ROOT.RooGaussian("gauss_H0", "gauss_H0", x, ROOT.RooFit.RooConst(10), ROOT.RooFit.RooConst(2))
gauss_H1 = ROOT.RooGaussian("gauss_H1", "gauss_H1", x, ROOT.RooFit.RooConst(12), ROOT.RooFit.RooConst(2))

# Generate toy templates
data_H0 = gauss_H0.generate(ROOT.RooArgSet(x), 10000)
data_H1 = gauss_H1.generate(ROOT.RooArgSet(x), 10000)

# Binned templates (same binning!)
hist_H0 = data_H0.binnedClone()
hist_H1 = data_H1.binnedClone()

# Create RooHistPdfs
pdf_H0 = ROOT.RooHistPdf("pdf_H0", "pdf_H0", ROOT.RooArgSet(x), hist_H0)
pdf_H1 = ROOT.RooHistPdf("pdf_H1", "pdf_H1", ROOT.RooArgSet(x), hist_H1)

# Create pseudo-data from H1 (to simulate a test)
pseudo_data = pdf_H1.generateBinned(ROOT.RooArgSet(x), 1000)

# Dummy parameter (needed by ModelConfig)
dummy = ROOT.RooRealVar("dummy", "dummy", 0.0, -1.0, 1.0)
poi = ROOT.RooArgSet(dummy)

# ModelConfig for H0
mc_H0 = ROOT.RooStats.ModelConfig("H0")
mc_H0.SetPdf(pdf_H0)
mc_H0.SetParametersOfInterest(poi)

# ModelConfig for H1
mc_H1 = ROOT.RooStats.ModelConfig("H1")
mc_H1.SetPdf(pdf_H1)
mc_H1.SetParametersOfInterest(poi)

# Run FrequentistCalculator
fc = ROOT.RooStats.FrequentistCalculator(pseudo_data, mc_H0, mc_H1)
fc.SetToys(500, 500)

result = fc.GetHypoTest()
result.Print()

print("\n--- Results ---")
print(f"p-value for H0: {result.NullPValue():.4f}")
print(f"Significance Z: {result.Significance():.2f}σ")

ROOT version

current master

Installation method

built from source

Operating system

ArchLinux

Additional context

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions