npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
npsi::MinuitSemiparametricFitFcn1D< Numeric, DensityConstructor, NumIn > Class Template Reference

#include <MinuitSemiparametricFitFcn1D.hh>

Inheritance diagram for npsi::MinuitSemiparametricFitFcn1D< Numeric, DensityConstructor, NumIn >:

Public Member Functions

 MinuitSemiparametricFitFcn1D (const npstat::HistoND< Numeric > &histo, const DensityConstructor &densityMaker, npstat::AbsSymbetaFilterProvider &fb, const npstat::BoundaryHandling &bm, const int symmetricBetaPower, const double minimumBgFeatureSize, const NumIn *initialApproximation=0, const unsigned lenApproximation=0U, const int polyDegreeLimit=-1, const bool verbose=true, const unsigned cvmode=npstat::CV_MODE_LINEARIZED, const bool useLeastSquaresCV=true, const bool refitBandwidth=true, const bool refitPolyDegree=true, const double regularizationParameter=-1.0, const unsigned nIntegrationPoints=0U, const double bandwidthUpperLimitFactor=5.0, const unsigned pseudoFitCycles=0U, const double convergenceEpsilon=0.0, const double pseudoFitPrecision=0.0, const unsigned bandwidthScanPoints=64U, const double minlog=log(DBL_MIN), const double up=0.5, const double upRefit=0.05, const unsigned maxIterations=10000U)
 
double Up () const
 
double lastBandwidthUsed () const
 
double lastPolyDegreeUsed () const
 
unsigned lastRegularized () const
 
double lastSignalFractionUsed () const
 
const std::vector< double > & lastBackgroundFitted () const
 
const std::vector< double > & lastSignalFitted () const
 
unsigned long callCount () const
 
double crossValidationPrecision () const
 
int symbetaPower () const
 
double maxBgEventsInGaussWindow () const
 
npstat::AbsSymbetaFilterProvidergetFilterProvider () const
 
std::vector< double > lastDensityFitted () const
 
virtual double operator() (const std::vector< double > &x) const
 

Protected Member Functions

double estimateMaxBandwidth () const
 
unsigned maxFilterDegree1D (const double nbg) const
 

Detailed Description

template<typename Numeric, class DensityConstructor, typename NumIn = double>
class npsi::MinuitSemiparametricFitFcn1D< Numeric, DensityConstructor, NumIn >

Target minimization function adapter class for running maximum likelihood density fits to histogrammed data by Minuit2 in which background is estimated by LOrPE and signal by a parametric model.

"Numeric" is the type of fitted histogram contents.

"DensityConstructor" is a functor which creates the necessary signal density function out of a vector of parameters. Must have "operator()(const std::vector<double>&) const" which returns an object (or a reference) of some class which was derived from AbsDistribution1D. "ScalableDensityConstructor1D" is an example of such a constructor class, appropriate in case only the signal fraction, location and scale are to be fitted but not the signal shape.

"NumIn" is the type of the array elements used to provide initial guess for the background density.

Note the special order of Minuit parameters which must be used with this class. See the comments to "operator()" for more detail.

Constructor & Destructor Documentation

◆ MinuitSemiparametricFitFcn1D()

template<typename Numeric , class DensityConstructor , typename NumIn = double>
npsi::MinuitSemiparametricFitFcn1D< Numeric, DensityConstructor, NumIn >::MinuitSemiparametricFitFcn1D ( const npstat::HistoND< Numeric > &  histo,
const DensityConstructor &  densityMaker,
npstat::AbsSymbetaFilterProvider fb,
const npstat::BoundaryHandling bm,
const int  symmetricBetaPower,
const double  minimumBgFeatureSize,
const NumIn *  initialApproximation = 0,
const unsigned  lenApproximation = 0U,
const int  polyDegreeLimit = -1,
const bool  verbose = true,
const unsigned  cvmode = npstat::CV_MODE_LINEARIZED,
const bool  useLeastSquaresCV = true,
const bool  refitBandwidth = true,
const bool  refitPolyDegree = true,
const double  regularizationParameter = -1.0,
const unsigned  nIntegrationPoints = 0U,
const double  bandwidthUpperLimitFactor = 5.0,
const unsigned  pseudoFitCycles = 0U,
const double  convergenceEpsilon = 0.0,
const double  pseudoFitPrecision = 0.0,
const unsigned  bandwidthScanPoints = 64U,
const double  minlog = log(DBL_MIN),
const double  up = 0.5,
const double  upRefit = 0.05,
const unsigned  maxIterations = 10000U 
)
inline

The constructor arguments are as follows:

histo – Naturally, the histogram to fit. It is assumed that the histogram bins are not scaled and contain the actual unweighted event counts.

densityMaker – This object will generate AbsDistribution1D objects for the signal model from the vector of signal parameters.

fb – "Filter builder". This object will generate local polynomial filters using densities from the symmetric beta family as weights. A reference implementation of such a class is provided with the NPStat software: "SimpleSymbetaFilterProvider". It may be possible to construct more efficient implementations which will reuse filters constructed for different bandwidth values.

bm – Method for handling LOrPE weight function at the boundaries of density support region.

symmetricBetaPower – This parameter determines the choice of the kernel. If it is negative, Gaussian kernel will be used, truncated at +- 12 sigma. If it is positive or 0, the kernel from the symmetric beta family will be used, proportional to (1 - x^2)^symmetricBetaPower. In my experience, most useful values of this parameter are -1 and 4.

minimumBgFeatureSize – Minimum feature size (like sigma of the Gaussian) of the background distribution that the nonparametric component of the fit should attempt to represent in full detail. Together with other things such as the number of events, this parameter will affect the smallest LOrPE bandwidth considered in the fit.

initialApproximation – Initial approximation for the background density (one array element per input histogram bin). Can be specified as NULL in which case the uniform density will be used as the initial approximation.

lenApproximation – Length of the initial approximation array. If not 0 (and if initialApproximation is not NULL), the code will verify that it equals the number of histogram bins.

polyDegreeLimit – The maximum polynomial degree to consider during cross validation (will be used as a limiting value of the corresponding MIGRAD parameter). Due to the round-off errors in calculating orthogonal polynomials, this number should not exceed 20 or so. The default value of -1 (and any other negative number) means that a reasonable limit estimate will be made automatically.

verbose – If "true", some info will be printed on the standard output while the fit is in progress.

cvmode – Mode for cross validation calculations. See comments to the "lorpeBackground1D" function for more detail on the meaning of this argument.

useLeastSquaresCV – "true" means use least squares cross validation. "false" means use pseudo likelihood.

refitBandwidth – If "true", the code will refit the bandwidth of the background model by cross validation for every value of signal parameters. In this case the user should fix the bandwidth parameter in the fit (it will be used as the initial guess only).

refitPolyDegree – If "true", the code will refit the polynomial degree of the background model by cross validation for every value of signal parameters. In this case the user should fix the polynomial degree parameter in the fit (it will be used as the initial guess only).

regularizationParameter – If this parameter is non-negative, the code will attempt to figure out the minimum reasonable value of the density estimate in cases that density is estimated to be zero at some point where data is present. This minimum density will be inversely proportional to pow(N, regularizationParameter). This will be applied during the likelihood calculation and in cross validation (limited to pseudo-likelihood CV, not done for least squares CV).

nIntegrationPoints – How many points to use in order to integrate the parametric signal density across each histogram bin. If this argument is specified as 0 then the difference of cumulative densities at the bin edges will be used, otherwise Gauss-Legendre quadrature will be employed (so that the number of points must be either 1 or one of the numbers supported by the "GaussLegendreQuadrature" class). For properly implemented densities, 0 should be the best option.

bandwidthUpperLimitFactor – This parameter determines the maximum kernel bandwidth which will be considered during cross validation. For Gaussian kernels, the maximum sigma will be set to the width of the histogram times this factor. For other kernels the maximum width will be adjusted accordingly (technically, the additional adjustment factor is determined by the "canonical bandwidth" ratio evaluated for the initial degree of the model polynomial).

pseudoFitCycles – Sometimes, when the initial guess of the bandwidth and polynomial degree is far away from optimal, Minuit has problems navigating towards the minimum in this 2-d space (the "narrow valley" problem). In this case it may be helful to make a number of steps at the beginning optimizing each variable in turn while keeping the other variable fixed. This parameter determines how many pairs of such initial steps to make during cross validation.

convergenceEpsilon – The background density is refitted iteratively by the relevant algorithm until convergence is achieved. The convergence criterion is that the L1 distance between the background distributions obtained in two successive iterations is less than this number. Must be non-negative. A reasonable value will be selected automatically in case default value of 0.0 is given.

pseudoFitPrecision – The Minuit working precision for maximizing the cross validation pseudo likelihood. Should be higher than the convergenceEpsilon by about an order of magnitude or so. Note that you will need to adjust precision of this fit as well. A reasonable value of "pseudoFitPrecision" will be selected automatically in case default value of 0.0 is given.

bandwidthScanPoints – If Minuit fails to optimize the quantity used in cross validation, the optimum will be found by simply scanning the bandwidth and the polynomial degree. This parameter determines the number of bandwidth points to scan.

minlog – This parameter limits the contribution of non-empty histogram bins into the log-likelihood in case the density was estimated to be 0 for that bin.

up – The Minuit "up" parameter which affects the definition of uncertainties. See the Minuit manual for details.

upRefit – The "up" parameter to use in the cross validation step.

maxIterations – The hard limit on the number of iterations that can be used for background determination. If convergence is not achieved after this number of iterations, an exception will be thrown.

This class will not assume ownership of any references. However, an internal copy will be made of the "initialApproximation" array if this array is not NULL.

Member Function Documentation

◆ lastRegularized()

template<typename Numeric , class DensityConstructor , typename NumIn = double>
unsigned npsi::MinuitSemiparametricFitFcn1D< Numeric, DensityConstructor, NumIn >::lastRegularized ( ) const
inline

The number of bins for which the background density was actually adjusted during the most recent run

◆ operator()()

template<typename Numeric , class DensityConstructor , typename NumIn = double>
virtual double npsi::MinuitSemiparametricFitFcn1D< Numeric, DensityConstructor, NumIn >::operator() ( const std::vector< double > &  x) const
inlinevirtual

This method returns the negative log likelihood.

Parameters must be given in a specific order:

x[0] – Value of the LOrPE bandwidth. Should be fixed in the fit if "refitBandwidth" was set "true" in the constructor.

x[1] – Degree of the LOrPE polynomial. Should be fixed in the fit if "refitPolyDegree" was set "true" in the constructor.

x[2] – Signal fraction. Can be either fixed or fitted.

x[3...] – These parameters will be passed to the density maker for building the signal density.


The documentation for this class was generated from the following file: