title: Poisson simulation not working as expected?
body: <p>I have a simple script to set up a Poisson distribution by constructing an array of "events" of probability = 0.1, and then counting the number of successes in each group of 10.  It almost works, but the distribution is not quite right (P(0) should equal P(1), but is instead about 90% of P(1)).  It's like there's an off-by-one kind of error, but I can't figure out what it is.  The script uses the Counter class from <a href="http://code.activestate.com/recipes/576611-counter-class/" rel="nofollow noreferrer">here</a> (because I have Python 2.6 and not <a href="http://docs.python.org/library/collections.html#collections.Counter" rel="nofollow noreferrer">2.7</a>) and the grouping uses itertools as discussed <a href="https://stackoverflow.com/questions/2095637/python-arguments-for-using-itertools-to-split-a-list-into-groups">here</a>.  It's not a stochastic issue, repeats give pretty tight results, and the overall mean looks good, group size looks good.  Any ideas where I've messed up?</p>
  
  <pre><code>from itertools import izip_longest
  import numpy as np
  import Counter
  
  def groups(iterable, n=3, padvalue=0):
      "groups('abcde', 3, 'x') --&gt; ('a','b','c'), ('d','e','x')"
      return izip_longest(*[iter(iterable)]*n, fillvalue=padvalue)
  
  def event():
      f = 0.1
      r = np.random.random()
      if r &lt; f:  return 1
      return 0
  
  L = [event() for i in range(100000)]
  rL = [sum(g) for g in groups(L,n=10)]
  print len(rL)
  print sum(list(L))
  
  C = Counter.Counter(rL)
  for i in range(max(C.keys())+1):
      print str(i).rjust(2), C[i]
  
  $ python script.py 
  10000
  9949
   0 3509
   1 3845
   2 1971
   3 555
   4 104
   5 15
   6 1
  $ python script.py 
  10000
  10152
   0 3417
   1 3879
   2 1978
   3 599
   4 115
   5 12
  </code></pre>