Day 5–10 days of Statistics — (HackerRank)

Celestial
3 min readJul 4, 2023

--

Day 5 of this challenge series comprises four parts/challenges that focus on the concepts of Poisson and Normal Distribution. In this blog, we will cover the Poisson distribution. In the next blog, we’ll delve into the Normal distribution.

To ensure a solid foundation, let’s begin by clarifying the fundamental concept before delving into the challenges.

Poisson distribution

  • Imagine you are at a coffee shop and you’re observing how many customers enter the shop every minute. Let’s say, on average, you expect 5 customers per minute. The Poisson distribution helps you understand the likelihood of different numbers of customers arriving in a given minute.
  • The Poisson distribution tells you the probability of observing a specific number of events (in this case, customers) in a fixed interval (one minute), given the average rate at which those events occur (5 customers per minute).
  • So, using the Poisson distribution, you can calculate the probabilities of different scenarios. For example:
  • What is the probability of having no customers in the next minute?
  • What is the probability of having exactly 3 customers in the next minute?
  • What is the probability of having more than 8 customers in the next minute?

The Poisson distribution allows you to answer questions like these by using the average rate (5 customers per minute) as a guide. It provides a way to estimate the likelihood of different outcomes, which can be useful in many areas, such as predicting customer arrivals, analyzing traffic patterns, or studying the occurrence of rare events.

In simple terms, the Poisson distribution helps us understand the chances of different events happening based on their average rate of occurrence.

Formula

Challenge # 1 — Poisson Distribution

Question -

Answer — 0.067

Explanation —

The mean value is provided as 2.5, and there is a fixed interval of 5 units. Now, let’s proceed by incorporating these values into a Python formula.

from math import factorial as fc
e, l, k = 2.71828, 2.5, 5
print(f'{(l**k * e**-l) / fc(k):.3f}')

Challenge #2 — Poisson Distribution II

Question —

Answer — 226.176 ,286.1

Explanation —

Based on the given logic of variance and expectation, we are aware of the expectation value, which corresponds to the mean provided in the question.

To proceed, let’s substitute the variable ‘x’ in the equation with ‘E[X**2]’ and obtain the result. This approach is commonly employed for Poisson random variables.

print(160 + 40*(0.88+0.88**2))
print(128 + 40*(1.55+1.55**2))

The blog journey continues! Follow me for more captivating content in the upcoming blogs.

--

--

Celestial
Celestial

Written by Celestial

Uncovering Patterns , Empowering Strategies.

No responses yet