0
0
SciPydata~10 mins

Poisson distribution in SciPy - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Poisson distribution
Start with lambda (rate)
Calculate PMF for k=0
Calculate PMF for k=1
Calculate PMF for k=n
Output probabilities for each k
The Poisson distribution calculates the probability of a number of events (k) happening in a fixed interval, given the average rate (lambda).
Execution Sample
SciPy
from scipy.stats import poisson
lambda_ = 3
k_values = range(6)
pmf_values = [poisson.pmf(k, lambda_) for k in k_values]
print(pmf_values)
This code calculates the Poisson probabilities for k=0 to 5 events when the average rate is 3.
Execution Table
Stepk (events)lambda (rate)PMF CalculationPMF Value
103poisson.pmf(0, 3) = e^-3 * 3^0 / 0!0.0498
213poisson.pmf(1, 3) = e^-3 * 3^1 / 1!0.1494
323poisson.pmf(2, 3) = e^-3 * 3^2 / 2!0.2240
433poisson.pmf(3, 3) = e^-3 * 3^3 / 3!0.2240
543poisson.pmf(4, 3) = e^-3 * 3^4 / 4!0.1680
653poisson.pmf(5, 3) = e^-3 * 3^5 / 5!0.1008
7End--Finished calculating PMF for k=0 to 5
💡 All PMF values for k=0 to 5 calculated using lambda=3
Variable Tracker
VariableStartAfter 1After 2After 3After 4After 5Final
kN/A012345
pmf_values[][0.0498][0.0498, 0.1494][0.0498, 0.1494, 0.2240][0.0498, 0.1494, 0.2240, 0.2240][0.0498, 0.1494, 0.2240, 0.2240, 0.1680][0.0498, 0.1494, 0.2240, 0.2240, 0.1680, 0.1008]
Key Moments - 2 Insights
Why does the PMF value for k=3 equal the value for k=2?
Because the Poisson formula depends on k and lambda, and for lambda=3, the probabilities for k=2 and k=3 happen to be very close, as shown in execution_table rows 3 and 4.
What does the lambda parameter represent in the Poisson distribution?
Lambda is the average number of events expected in the interval. It is fixed at 3 in this example, as shown in every row of the execution_table.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the PMF value when k=4?
A0.2240
B0.1680
C0.1008
D0.0498
💡 Hint
Check the row where k=4 in the execution_table under PMF Value column.
At which step does the PMF calculation for k=1 happen?
AStep 3
BStep 1
CStep 2
DStep 4
💡 Hint
Look at the Step column in execution_table for k=1.
If lambda was increased to 5, how would the PMF values for k=0 to 5 change?
AValues for higher k would increase, lower k decrease
BThey would all decrease
CThey would all increase
DValues for lower k would increase, higher k decrease
💡 Hint
Recall that lambda controls the average rate; higher lambda shifts probabilities toward higher k.
Concept Snapshot
Poisson distribution models count of events in fixed time.
Syntax: poisson.pmf(k, lambda)
Outputs probability of k events given average rate lambda.
PMF sums to 1 over all k.
Useful for rare event counts.
Lambda is mean and variance.
Full Transcript
The Poisson distribution calculates the chance of a number of events happening in a fixed time, based on an average rate called lambda. We calculate the probability for each number of events k using the formula poisson.pmf(k, lambda). In the example, lambda is 3, and we find probabilities for k from 0 to 5. The probabilities show how likely each count is. For instance, the chance of 0 events is about 5%, and for 3 events about 22%. Lambda controls the shape: higher lambda shifts probabilities to higher counts. This helps us understand event counts like calls per hour or arrivals per minute.