Amira knows that the time it takes her to commute to work is approximately normally distributed with a mean of 45 minutes and a standard deviation of 3 minutes. What time must she leave home in the morning so that she is 95% sure of arriving at work by 9.00am?
Assume that random variable "X" denotes a time that Amira needs to arive at work.
We need to find such a minimum number "\\alpha" that "P(X\\leq\\alpha)=0.95". We remind that the density fo the normal distribution with parameters "\\mu=45" and "\\sigma=3" is: "p(x)=\\frac{1}{\\sigma\\sqrt{2\\pi}}e^{-\\frac12(\\frac{x-\\mu}{\\sigma})^2}=\\frac{1}{3\\sqrt{2\\pi}}e^{-\\frac12(\\frac{x-45}{3})^2}" . Thus, "P(X\\leq\\alpha)=\\int_{-\\infty}^{\\alpha}\\frac{1}{3\\sqrt{2\\pi}}e^{-\\frac12(\\frac{x-45}{3})^2}dx". The latter yields "0.95" in case "\\alpha=49.94". We used the following code in Anaconda to get the result:
from scipy import integrate
import numpy as np
import math
func = lambda x:(1/(3*math.sqrt(2)*math.sqrt(math.pi)))*math.exp(-1/2*((x-45)/3)*((x-45)/3))
e = integrate.quad(func, -np.inf, 49.94)
print(e)
We subsituted different values in the command "integrate.quad" to get the result
Thus, it is enough to leave at 8.10 (more precisely, at 8.10 and 6 seconds) to arrive at work till 9.00am.
Comments
Leave a comment