scippuncertainty.mc.accumulator.VarianceAccum#
- class scippuncertainty.mc.accumulator.VarianceAccum(*, keep_samples=False)[source]#
Compute the mean and variance of bootstrap samples.
The mean \(\mu_i\) and variance \(\sigma_i^2\) for array element \(i\) are defined as
\[\begin{split}\mu_i &= \frac{1}{N} \sum_{s=1}^{N} x_{i s} \\ \sigma_i^2 &= \frac{1}{N-1} \sum_{s=1}^{N} (x_{i s} - \mu_i)^2, \\\end{split}\]where the sums run over the Monte-Carlo samples.
The computation of variances uses an algorithm based on [Wel62] and [CGL82]. This reduces the risk of catastrophic cancellations from sums of squares compared to a naive implementation.
- __init__(*, keep_samples=False)[source]#
Initialize a CovarianceAccum instance.
- Parameters:
keep_samples (
bool, default:False) – IfTrue, all samples are kept and returned as an attribute calledsampleswith dimensionmonte_carlo.
Methods
__init__(*[, keep_samples])Initialize a CovarianceAccum instance.
add(sample)Register a single sample.
add_from(other)Merge results from
otherintoself.get()Return the current result.
new()Return a new VarianceAccum.