# SumW2Error gives unexpected results with unweighted datasets, BatchMode

**URL:** <https://root-forum.cern.ch/t/sumw2error-gives-unexpected-results-with-unweighted-datasets-batchmode/47206>\
**Category:** Roofit and RooStats\
**Tags:** bug, roofit\
**Created:** [October 12, 2021, 4:57pm UTC](https://root-forum.cern.ch/t/sumw2error-gives-unexpected-results-with-unweighted-datasets-batchmode/47206 "2021-10-12T16:57:10Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [October 13, 2021, 8:20am UTC](https://root-forum.cern.ch/t/sumw2error-gives-unexpected-results-with-unweighted-datasets-batchmode/47206/2 "2021-10-13T08:20:41Z")

</div>

Hi,

1. I agree this should be probably documented better. However it is important to understand what is happening. When SumW2Error is enable a first minimization is performed of the weighted likelihood followed by a second one where the likelihood is minimized using the square of the weights. This is for obtained the matrix C, used for the correction for the Covariance matrix as documented [here](https://root.cern.ch/doc/master/classRooAbsPdf.html#a5f79f16f4a26a19c9e66fb5c080f59c5).
2. It should not make a difference, because in that case the matrix `C = V`, where C is the covariance matrix obtained from the weight square likelihood and V from the weighted likelihood. If all the weights are 1 it is clear then that C must be equal to V.  
However, if the fit is unstable, it is possible that calling again Hesse, you get a different matrix. This is something to check for that particular problem.
3. It should not, I suspect it is something caused by the instability of that fit
4. Also in Batch mode, if the fit is not stable you might expect to get a different result, since the computation is performed differently, causing a different result within the numerical error

Cheers

Lorenzo

---

_[View the full topic](https://root-forum.cern.ch/t/sumw2error-gives-unexpected-results-with-unweighted-datasets-batchmode/47206)._
