Hi all,

I use the G4GeneralParticleSource class and UI comands to define a particle source with energy spectrum. Let’s denote the spectrum `p_i`

, and `i`

is the index of bins related to energy. In a run (sampling) `N`

particles are simulated. If we focus on a perticular bin `i`

, then this bin should have `N*p_i`

particles . But the number `N*p_i`

is its expectation value, not the real number of particles in the bin `i`

, and the real number in bin `i`

is not same in each run. Since it’s a binomial distribution with probability `p_i`

and `N`

times expriments, its real number generated in bin `i`

should have variance `var=N*p_i(1-p_i)`

My question is that can geant4 handle this randomness automaticly or it only generate `N*p_i`

particles in the bin `i`

? I don’t know that if I defined a energy spectrum using UI command `/gps/hist/point energy probability`

do I need some commands to deal with the randomness of its distribution.