Skip to content

[RF] Document rho and Mirror options of RooKeysPdf - #22994

Open
ArneshBanerjee wants to merge 3 commits into
root-project:masterfrom
ArneshBanerjee:rookeyspdf-mirror-rho-docs
Open

[RF] Document rho and Mirror options of RooKeysPdf#22994
ArneshBanerjee wants to merge 3 commits into
root-project:masterfrom
ArneshBanerjee:rookeyspdf-mirror-rho-docs

Conversation

@ArneshBanerjee

Copy link
Copy Markdown

This adds documentation for RooKeysPdf, addressing #8507.

The rho and Mirror constructor parameters were not documented, and
the Mirror enum values had cryptic names with no explanation. This PR:

  • Documents rho as the overall scale factor for the kernel width.
  • Explains the boundary bias and how symmetric vs asymmetric mirroring
    correct it, with a one-line description for each Mirror enum value.
  • Documents every parameter of both public constructors.
  • Adds a pointer to RooNDKeysPdf for the multi-dimensional case.

The descriptions are based on the existing implementation: how the
mirror flags are set in the constructor and how the reflected events
are added (symmetric) or subtracted (asymmetric) in LoadDataSet. This
is a documentation-only change, so no test is added.

Add Doxygen documentation for the rho bandwidth scale factor and the
Mirror boundary-correction options, and document each constructor
parameter. Also point to RooNDKeysPdf for the multi-dimensional case.

Closes root-project#8507.

@ferdymercury ferdymercury left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! Some comments from my side


Cranmer KS, Kernel Estimation in High-Energy Physics.
Computer Physics Communications 136:198-207,2001 - e-Print Archive: hep ex/0011057

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was some discussion wrt the sqrt(12) in the code, the original author said:

My memory of this is that in some cases instead of processing a set of unbinned data the input was a finely binned histogram. In this case, data that might be uniformly spread in a histogram bin would then be aggregated into a single sample with no variance. I believe that is why the kernel has Alpha/(2.0*Sqrt(3.0)) corresponding to the std. deviation of a uniform / rectangular distribution corresponding to the histogram bin.

maybe worth adding a note on this regard ?

Comment thread roofit/roofit/src/RooKeysPdf.cxx Outdated
@@ -28,6 +28,24 @@

Cranmer KS, Kernel Estimation in High-Energy Physics.
Computer Physics Communications 136:198-207,2001 - e-Print Archive: hep ex/0011057

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


/** \class RooKeysPdf
\ingroup Roofit

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 6 to 8
* GR, Gerhard Raven, UC San Diego, raven@slac.stanford.edu *
* DK, David Kirkby, UC Irvine, dkirkby@uci.edu * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
* *

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* GR, Gerhard Raven, UC San Diego, raven@slac.stanford.edu *
* DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
* WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
* *

* *
* Redistribution and use in source and binary forms, *
* with or without modification, are permitted according to the terms *
* listed in LICENSE (http://roofit.sourceforge.net/license.txt) *

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line seems outdated?

Class RooKeysPdf implements a one-dimensional kernel estimation p.d.f which model the distribution
of an arbitrary input dataset as a superposition of Gaussian kernels, one for each data point,
each contributing 1/N to the total integral of the pdf.
If the 'adaptive mode' is enabled, the width of the Gaussian is adaptively calculated from the

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
\note KEYS stands for Kernel Estimating Your Shapes, see https://web.archive.org/web/20010604031632/http://www-wisconsin.cern.ch/~cranmer/KEYS.pdf
If the 'adaptive mode' is enabled, the width of the Gaussian is adaptively calculated from the

Add references to Cranmer's KEYS package and the paper DOI, note the
uniform-distribution origin of the 2*sqrt(3) factor in the kernel
width, and fix the author line formatting in the header.
@ArneshBanerjee

Copy link
Copy Markdown
Author

Thanks a lot for the suggestions @ferdymercury, they have been done in the latest commit:

  • Added the note that KEYS stands for Kernel Estimating Your Shapes, with the archived write-up link, and a link to the original KEYS web page.
  • Added the DOI hyperlink for the Cranmer paper.
  • Added a comment explaining that the 2*sqrt(3) factor is the standard deviation of a uniform distribution, for the finely binned histogram case you mentioned.
  • Fixed the author line in the header so Wouter Verkerke is on its own line.

On the listed in LICENSE (http://roofit.sourceforge.net/license.txt) line: that URL is the shared boilerplate used in about 50 RooFit headers, so I left it here to avoid making this one file inconsistent with the rest. Happy to update it everywhere in a separate PR if you prefer.

Comment thread roofit/roofit/src/RooKeysPdf.cxx Outdated
double h=std::pow(double(4)/double(3),0.2)*std::pow(_sumWgt,-0.2)*_rho;
double hmin=h*sigmav*std::sqrt(2.)/10;
// The 2*sqrt(3) factor comes from the standard deviation of a uniform
// distribution, sqrt(12)/2. This accounts for the case where the input is a

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// distribution, sqrt(12)/2. This accounts for the case where the input is a
// distribution, 1/sqrt(12). This accounts for the case where the input is a

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ArneshBanerjee

Copy link
Copy Markdown
Author

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants