NUISANCEMC / nuisance

github mirror of the NUISANCE neutrino interaction generator comparison tool. Compare your favourite neutrino interaction generators to each other and over 350 published data sets
https://nuisance.hepforge.org
GNU General Public License v3.0
11 stars 21 forks source link

Some fixes in StatUtils to help inversion in edge cases #68

Open nitish-nayak opened 1 month ago

nitish-nayak commented 1 month ago

There seems to be a couple of issues when running SVDDecomp, which is done to force inversion when Cholesky doesn't converge. Particularly, for certain cases when there's a large number of bins in the covariance matrix :

2x2 matrix is as follows

 |      0    |      1    |

0 | 4 2 1 | 1 4

root [3]

It makes it _symmetric_ however once this object is cloned
```cpp
root [3] TMatrixDSym b = *((TMatrixDSym *)a.Clone("new"))
(TMatrixDSym &) Name: TMatrixTSym<double> Title: 
root [4] b.Print()

2x2 matrix is as follows

     |      0    |      1    |
-------------------------------
   0 |          4           2 
   1 |          2           4 

The consequence of this is that GetChi2FromCov returns a different value than what one would expect by directly calculating the chisq on the SVD inverse. This can be a fair bit different depending on the scenario. The value also changes depending on the scaling done on the input covariance even if its scaled back to the measurement in the end. One can fix this by just copying the contents of the SVD inverse into calc_cov directly instead of using TMatrixDSym->Clone()

One other change is to set the tolerance for Cholesky decomposition to the minimum double value instead of 10^-76