This Python code calculates and plots the Probability Mass Function (PMF) for a Poisson distribution. It allows you to specify the number of events (k) and the rate at which the events occur (lambda).
The code consists of a Python function called poisson_pmf(k, lambda_val)
that takes two parameters:
k
: Number of events to occur at the same time.lambda_val
: Lambda value, which represents the rate at which the events occur.
The function performs the following tasks:
- Calculates the Poisson PMF for a given
k
andlambda_val
. - Prints out the probability that
k
events occur at the same time with the specified lambda value. - Plots the PMF from 0 to
k
occurrences using Matplotlib.
Here's an example of how to use the function:
poisson_pmf(k=10, lambda_val=5)
The code uses the following Python libraries:
- Numpy
- Matplotlib
- SciPy