Hi,
I am trying to use a RooParametricStepFunction to fit a simple 1d dataset, and I have what I believe is a normalization problem.
I set the allowed range for all of the n-1 bin value parameters to be (0.0, 1.0), but rather than being properly normalized, I find that the fit simply sends all of the parameters to the maximum value of 1.0.
I believe the problem is that the normalization condition for the RooParametricStepFunction is enforced by constraining the value of the last bin from the n-1 parameters. However, in the evaluation of the pdf value, negative values of the last bin are truncated to 0, whereas in the normalization, a negative value is assumed in case the sum of the rest of the distribution exceeds 1.
I think the proper solution is also to truncate the last bin value when doing the normalization integral. I fixed this for my part by changing the beginning of the analyticalIntegral function for RooParametricStepFunction to read:
Double_t lastbinval = lastBinValue();
if (!rangeName && lastbinval>=0) {
return 1.0 ;
}
Double_t xmin = _x.min(rangeName) ;
Double_t xmax = _x.max(rangeName) ;
Double_t sum=0 ;
Int_t i ;
for (i=1 ; i<=_nBins ; i++) {
Double_t binVal = (i<_nBins) ? (static_cast<RooRealVar*>(_coefList.at(i-1))->getVal()) : max(0.0,lastbinval) ;
...
And now my fit behaves as expected.
Thanks,
Josh