title: Getting a smooth Poisson Distribution over a Histogram with Small Number of Bins
body: <p>I have a Poisson distribution of a background count which mostly contains counts equal to zero, I've fitted a Poisson distribution to this data and gotten the following result:</p>
  <p><a href="https://i.stack.imgur.com/uFz7D.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uFz7D.png" alt="Histogram for background data with Poisson distribution" /></a></p>
  <p>I have another dataset from a source which has higher count rates, in this case it works fine:
  <a href="https://i.stack.imgur.com/tUPik.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tUPik.png" alt="Histogram for source data with Poisson distribution" /></a></p>
  <p>Here's my (inelegant) code in full;</p>
  <pre><code>mean_values = []
  # obtaining results:
  for a in data_arrays:
      dataset = globals()[a]
      cps_vals = dataset[:,1]
      max_cps = int(max(cps_vals))
      mean_name = a +&quot;_mean&quot;
      std_name = a + &quot;_std&quot;
      serr_name = a + &quot;_serr&quot;
      mean = globals()[mean_name] = np.mean(cps_vals)
      globals()[std_name] = np.std(cps_vals,ddof=1)
      globals()[serr_name] = globals()[std_name]/np.sqrt(len(cps_vals)) ## I used globals() so I could call in e.g. the background serr as the variable bg_serr.
      print(a,&quot;mean:&quot;,globals()[mean_name],&quot;sqrt(mean):&quot;,np.sqrt(globals()[mean_name]),&quot;std:&quot;,globals()[std_name],&quot;serr:&quot;,globals()[serr_name],&quot;sqrt(lambda)/sigma =&quot;,np.sqrt(globals()[mean_name])/globals()[std_name])
      
      # plotting with Poisson:
      
      plt.figure()
      bin_edges = np.arange(0, max_cps+1.1, 1)
      histogram = plt.hist(cps_vals,density=True,bins=bin_edges)
      plt.xlabel(&quot;Counts Per Second&quot;)
      plt.ylabel(&quot;Probability of Occurence&quot;)
      pops = histogram[0]
      bins = histogram[1]
      
      maxidx = np.argmax(pops)
      maxpop = pops[maxidx]
      maxbin = np.max(bins)
      most_populated_bin = bins[maxidx]
      
      plt.plot(np.arange(0, maxbin), poisson.pmf(np.arange(0,maxbin), 
      np.mean(cps_vals)),c=&quot;black&quot;)
  </code></pre>
  <p>This is the relevant line for the Poisson plot:</p>
  <p><code>plt.plot(np.arange(0, maxbin), poisson.pmf(np.arange(0,maxbin), np.mean(cps_vals)),c=&quot;black&quot;)</code></p>
  <p>If I try to make the np.arange spacing smaller, I get ringing in the Poisson curves:</p>
  <p><a href="https://i.stack.imgur.com/zRWqC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zRWqC.png" alt="enter image description here" /></a>
  <a href="https://i.stack.imgur.com/hiBmD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hiBmD.png" alt="enter image description here" /></a></p>
  <p>I think this is because it needs integer values of counts?</p>
  <p>How can I produce a smooth Guassian curve for the background count? The one I'm getting doesn't look right.</p>