Mean / Variance confusion in save_fits function of optimize_KL
While finishing some plots I was surprised by a very high standard deviation and wanted to check if this could be true. Then I found this:
if mean or std:
m, s = self.sample_stat(op)
if mean:
self._save_fits_2d(m, file_name_base + "_mean.fits", overwrite)
if std:
self._save_fits_2d(s, file_name_base + "_std.fits", overwrite)
here: https://gitlab.mpcdf.mpg.de/ift/nifty/-/blob/NIFTy_8/src/minimization/sample_list.py#L224
So in the 'if std:' we save something called standard deviation.
But sample_stat returns the mean and the variance:
def sample_stat(self, op=None):
"""Compute mean and variance of samples after applying `op`.
Parameters
----------
op : callable or None
Callable that is applied to each item in the :class:`SampleListBase`
before it is used to compute mean and variance.
Returns
-------
tuple
A tuple with two items: the mean and the variance.
"""
from ..probing import StatCalculator
if self.n_samples == 1:
res = self.average(op)
return res, 0*res
sc = StatCalculator()
for ss in self.iterator(op):
sc.add(ss)
return sc.mean, sc.var
here: https://gitlab.mpcdf.mpg.de/ift/nifty/-/blob/NIFTy_8/src/minimization/sample_list.py#L348
So I think we should take the square root here.... @gedenhof @pfrank I address also @parras, since he worked a lot on the whole optmize-kl and sample-list part of nifty.