Day 6 - The Central Limit Theorem

Problem 1

A large elevator can transport a maximum of \(9800\) kg. Suppose a load of cargo containing \(49\) boxes must be transported via the elevator. The box weight of this type of cargo follows a distribution with a mean of \(\mu=205\) kg and a standard deviation of \(\sigma=15\) kg. Based on this information, what is the probability that all boxes can be safely loaded into the freight elevator and transported?

Mathematical explanation

This problem can be tackled with the central limit theorem. Since the number of boxes is "large", the sum of the weight approaches normal distribution with : * \(\mu' = n\mu\) * \(\sigma'=\sigma\sqrt{n}\)

If we want to know the probability of the sum of the mass of all boxes to be under a certain weight, we can compute the cumulative density function :

$$P(x<9800) = F_X(9800)$$
max_load = 9800
n = 49
mu = 205
st_dev = 15

import math

def cumulative(x,mean,sd):
    return 0.5*(1+math.erf((x-mean)/(sd*math.sqrt(2))))


mu_group = n*mu
st_dev_group = st_dev*math.sqrt(n)

print(f"Probability that all the boxes can be lifted by the elevator : {cumulative(max_load, mu_group, st_dev_group)}")
Probability that all the boxes can be lifted by the elevator : 0.009815328628645315

Problem 2

The number of tickets purchased by each student for the University X vs. University Y football game follows a distribution that has a mean of \(\mu=2.4\) and a standard deviation of \(\sigma=2.0\).

A few hours before the game starts, \(100\) eager students line up to purchase last-minute tickets. If there are only \(250\) tickets left, what is the probability that all students will be able to purchase tickets?

Mathematical explanation

We want to know if the sum of all the purchases will exceed the total supply of tickets. Since each student buy follows a Normal distribution and that the number of students is relatively high, the probability that all the students will be able to buy a ticket can be computed by applying the central limit theorem. The total number of tickets bought follows a normal distribution of mean \(\mu'=n*\mu\) and of standard deviation \(\sigma'=\sigma\sqrt{n}\)

ticket_supply = 250
n_students = 100
mu = 2.4
st_dev = 2


mu_group = n_students*mu
st_dev_group = st_dev*math.sqrt(n_students)

print(f"Probability that all the students can purchase tickets : {cumulative(ticket_supply, mu_group, st_dev_group)}")
Probability that all the students can purchase tickets : 0.691462461274013

Problem 3

You have a sample of \(100\) values from a population with mean \(\mu=500\) and with standard deviation \(\sigma=80\). Compute the interval that covers the middle \(95%\) of the distribution of the sample mean; in other words, compute \(A\) and \(B\) such that \(P(A<x<B)=0.95\). Use the value of \(z=1.96\). Note that is the z-score.

Mathematical explanation

The margin of error can be computed with :

$$MoE = \frac{z-\sigma}{\sqrt{n}}$$

Knowing this, we can figure out what values for x paint the exact middle of the distribution for 0.95 probability, that means theres a 0.0025 leftover on both sides to make the total of 1.

zScore = 1.96
std = 80
n = 100
mean = 500

marginOfError = zScore * std / math.sqrt(n);
print("A =",mean- marginOfError)
print("B =",mean + marginOfError)
A = 484.32
B = 515.68