Statistical error / uncertainty

Hi,

is there any feature to receive the statistical error resp. uncertainty of a simulation. Afaik Monte carlo simulation usually provide quantities like these(?), is there also something available for G4?

My actual purpose is to determine how many photons I should generate to get stable results.

The answer depends on how you are getting your results. If it is via scoring , Geant4 provides stat. error, if you make an histogram, for example in ROOT, ROOT provides error bars in each bin

1 Like

Thank you, yes, I’m making histograms via ROOT. How do I get an error bar, there?
I’m reading out a tree and creating a tree quite directly.

If you fill a histogram from a branch, then ROOT will compute symmetric error bars for you. You can have them drawn by specifying one of the “E” options to Draw().

If you do your own analysis, then you get to do stuff like compute sum of weights, sum of squared weights, etc. Woo hoo…

1 Like

Thanks a lot, that worked quite flawlessly.

For my understanding: What exactly do these error bars represent?

For an unweighted histogram, they are sqrt(N) (“RMS”, “one sigma”) for each bin. For weights, they are sqrt(sum-weights) for each bin. See the ROOT documentation for more details, and for options to display error-on-the-mean, or asymmetric (Poissonian) error bars.

1 Like

As usually, thanks a lot for all your help and inputs! The question is cleared but I’m still unsure of how many photons (or particles, generally spoken) I’ve to generate. How can I determine this?
Is there a thumb of rule for G4 or purposes? Can I use some calculated values?

Geant4 generates events, not “activity,” so what you’d need to do is understand first what your source activity is, and what time interval you want to simulate. The product of those two is the number of events.

Having said that, the next question is what uncertainty do you want (1%, 0.1%, 10% whatever…)? The relative uncertainty goes like 1/sqrt(N), so you can use that to estimate the number of events you need. Given the number of events, you can rescale to time interval or activity as needed.

1 Like