# How exactly does RooPlot::chisquare() compute the result?

**URL:** <https://root-forum.cern.ch/t/how-exactly-does-rooplot-chisquare-compute-the-result/36388>\
**Category:** Roofit and RooStats\
**Created:** [October 17, 2019, 3:17pm UTC](https://root-forum.cern.ch/t/how-exactly-does-rooplot-chisquare-compute-the-result/36388 "2019-10-17T15:17:34Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![StephanH](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@StephanH](https://root-forum.cern.ch/u/StephanH)\
**Post date:** [October 18, 2019, 8:31am UTC](https://root-forum.cern.ch/t/how-exactly-does-rooplot-chisquare-compute-the-result/36388/3 "2019-10-18T08:31:56Z")

</div>

Hi Sebastian,

we discussed Chi2 a bit in this thread here:

> [@Strange behaviour with maximum likelihood fit in roofit](https://root-forum.cern.ch/t/strange-behaviour-with-maximum-likelihood-fit-in-roofit/36224):
>
> Hi all, I am doing a 2D extended maximum likelihood fit in RooFit (primarily binned but I am also summarizing the results from the unbinned version of it). Data-Set = Signal (peak in both the variables ) and background (flat in both the variables) (the reason of 2D fit is I have other backgrounds which are peaking, but for now, to isolate the problem I just mention flat background). Below are the results from binned and unbinned extended maximum likelihood fits. All the pdf shape parameters …

A very important difference is that the chi2 from the plot is calculated in terms of plot bins, and it is divided by ndf, but the number of fit parameters is **not** subtracted from ndf. The Chi2Var just computes Chi2 (no ndf), and it does that in bins of the observable(s), which don’t necessarily coincide with the plot bins.

For the bin errors, the histogram uses asymmetric Poisson errors. Bins that have a model prediction of zero are skipped.

---

_[View the full topic](https://root-forum.cern.ch/t/how-exactly-does-rooplot-chisquare-compute-the-result/36388)._
