### Function Reference: `poissfit`

statistics: lambdahat = poissfit (x)
statistics: [lambdahat, lambdaci] = poissfit (x)
statistics: [lambdahat, lambdaci] = poissfit (x, alpha)
statistics: [lambdahat, lambdaci] = poissfit (x, alpha, freq)

Estimate parameter and confidence intervals for the Poisson distribution.

`lambdahat = poissfit (x)` returns the maximum likelihood estimate of the rate parameter, lambda, of the Poisson distribution given the data in x. x must be a vector of non-negative values.

`[lambdahat, lambdaci] = poissfit (x)` returns the 95% confidence intervals for the parameter estimate.

`[lambdahat, lambdaci] = poissfit (x, alpha)` also returns the `100 * (1 - alpha)` percent confidence intervals of the estimated parameter. By default, the optional argument alpha is 0.05 corresponding to 95% confidence intervals. Pass in `[]` for alpha to use the default values.

`[…] = poissfit (x, alpha, freq)` accepts a frequency vector or matrix, freq, of the same size as x. freq typically contains integer frequencies for the corresponding elements in x. freq cannot contain negative values.

Further information about the Poisson distribution can be found at https://en.wikipedia.org/wiki/Poisson_distribution

See also: poisscdf, poissinv, poisspdf, poissrnd, poisslike, poisstat

Source Code: poissfit

### Example: 1

     ## Sample 3 populations from 3 different Poisson distibutions
     randp ("seed", 2);    # for reproducibility
     r1 = poissrnd (1, 1000, 1);
     randp ("seed", 2);    # for reproducibility
     r2 = poissrnd (4, 1000, 1);
     randp ("seed", 3);    # for reproducibility
     r3 = poissrnd (10, 1000, 1);
     r = [r1, r2, r3];

     ## Plot them normalized and fix their colors
     hist (r, [0:20], 1);
     h = findobj (gca, "Type", "patch");
     set (h(1), "facecolor", "c");
     set (h(2), "facecolor", "g");
     set (h(3), "facecolor", "r");
     hold on

     ## Estimate their lambda parameter
     lambdahat = poissfit (r);

     ## Plot their estimated PDFs
     x = [0:20];
     y = poisspdf (x, lambdahat(1));
     plot (x, y, "-pr");
     y = poisspdf (x, lambdahat(2));
     plot (x, y, "-sg");
     y = poisspdf (x, lambdahat(3));
     plot (x, y, "-^c");
     xlim ([0, 20])
     ylim ([0, 0.4])
     legend ({"Normalized HIST of sample 1 with λ=1", ...
              "Normalized HIST of sample 2 with λ=4", ...
              "Normalized HIST of sample 3 with λ=10", ...
              sprintf("PDF for sample 1 with estimated λ=%0.2f", ...
                      lambdahat(1)), ...
              sprintf("PDF for sample 2 with estimated λ=%0.2f", ...
                      lambdahat(2)), ...
              sprintf("PDF for sample 3 with estimated λ=%0.2f", ...
                      lambdahat(3))})
     title ("Three population samples from different Poisson distibutions")
     hold off