Odds of specific generated population of exponential distributed stochast I'm trying to generate a sequence of samples using an exponentially distributed stochast, i.e., making a Poisson arrival process.
In my specific case I generate 337 samples using a mean inter-arrival   of 64117.
Intuitively I'd expected the sum of the samples to be close to 337 * 64117.
However I see sums which deviate with more than 10% from the above term.
Of course it's stochastic and it's possible, but how can I analytically quantify the odds of the population's sum to deviate more than, say, 10% for this poulation size?
Basically I want to test if the implementation for the Poisson process is sound.
For convenience, I used the following one-liner in Python:
p=64117; n=337; n / (sum (map(lambda i: numpy.random.exponential(p), range(n))) / p)

For showing the difference between observed sum and expected sum as a ratio.
 A: The sum of exponential distributions is the Gamma distribution, and more specifically the Erlang distribution, which take the -- shape (amount of independent exponential variables) and scale (common mean of the exponential variables) -- parameters
For all intent and purposes hereafter we can use the Gamma distribution.
In this case numpy will not help and you need the scipy.stats module which gives you a convenient CDF function for the gamma distribution
To calculate the odds of your sum of samples to be smaller or larger than 10% of the expected value, you'd do (taken from interactive iPython session):
In [362]: scipy.stats.gamma.cdf(0.90*337*64117,337, 0, 64117)
Out[362]: 0.029886065690788766

In [363]: scipy.stats.gamma.cdf(1.10*337*64117,337, 0, 64117)
Out[363]: 0.9637460040599366

In [364]: Out[362] + (1 - Out[363])
Out[364]: 0.066140061630852162

So, roughly a chance of 6.6 percent for the sum of you distributed variables to have a deviation of more than 10% from the expected value.
