# Statistical Error calculations

Dear FLUKA experts,

When writing user routines, how can I calculate the statistical error?
I am using mgdraw.f in the ENTRY BXDRAW in order to get energy, position and direction of photons crossing a boundary.

Hen Shukrun

Dear @rachel.hen.shukrun ,

FLUKA estimates the statistical error by calculating the variance of the means \sigma^{2}_{<x>} of quantity x, in N batches.

\sigma^{2}_{<x>} = \frac{1}{N-1} \left[ \frac{\sum^{N}_{1} n_{i} x^{2}_{i}}{n} - \left( \frac{\sum^{N}_{1} n_{i} x_{i}}{n} \right)^{2} \right] = \frac{\text{mean of squares} - \text{square of means}}{N-1}

where
n_{i} = number of histories (primaries) in the \text{i}^{\text{th}} batch (cycle)
n = \sum n_{i} = total number of histories in the N batches
x_{i} = the average of x in the \text{i}^{\text{th}} batch

x_{i} = \sum_{j=1}^{n_{i}} \frac{x_{ij}}{n_{i}}

x_{ij} = the contribution to x of the \text{j}^{\text{th}} history in the \text{i}^{\text{th}} batch

This calculations could be simply implemented in your program processing your results created by mgdraw.

Cheers,
David

1 Like