Fit Poisson ditribution to histogram

Is there a way how to fit a Poisson distribution (determine the lambda parameter) from a histogram of an experimental process?

In the experimental setup, in each event we are recording the number of detected photons and the experiment records the histogram of a huge number of the observation. So, I don’t have access to the recordings of each observations - I can only acces the histogram of a huge number of observations.

However, the, x) expects that I can provide an array of observations. Is there a way how to use the histogram instead and fit lambda parameter of the Poisson distribution to the histogram?

There might be more ready-to-go options, but otherwise you can use LsqFit to fit your data as you wish:

For a Poisson distribution lambda is just the mean of your data, which you can compute from your histogram.That said it would be nice to have interface that can take histogram-like data, since those are quite common. Otherwise better use maximum likelihood than least-square to fit a distribution.


Adding to previous answers, if you only have access to samples in a stream of data, consider using OnlineStats.jl to compute the mean as the parameter of the distribution you are after.

As mentioned above the MLE would just be the mean, and then Poisson(lambda) would be the fitted distribution.

One perhaps more general possibility is to think about what a histogram is at the core and how you can potentially simulate data from the histogram itself. You are basically binning the data, and then each bin can be approximated by a Uniform(a,b) distribution. And if you have the proportion of the data in each bin (based on the Y-axis) you can approximate the empirical CDF. You now will also have the empirical CDF cutoffs for each bin.

Then you just simulate P from a Uniform(0,1) distribution and where P lands determines the bin to simulate from Uniform(a,b).

This leads to approximate data mimicking, and you can repeat the procedure many times to get a simulated mean (or whatever else).

But really if you have the mean value then that already gives you the maximum likelihood Poisson fit. The algorithm above is more of a nonparametric method that can be useful for other things too.