Choose below the probability distribution that best fits the described process. Choose only from Bernoulli, Geometric, Binomial, Poisson, Exponential, and Normal. 1 Points each.
Plot the probablities using Python. Accurately label x and y axis. State which distribution the plot is decribing. Make distinction in the use of discrete or continuous variables in the plots. Use for
loops to compute probabilities.
[8 points] The probability of rain is 0.3 in a given day. Plot the number days it will rain and their corresponding probilities in a given month of 31 days. Show the expected value of the distribution as a red vertical line in the plot.
[6 points]Probability of death cancer is 5%. Compute the probability of any number of people dying from cancer in group of 100 people
In [2]:
import matplotlib.pyplot as plt
import numpy as np
#set parameter
p = 0.2
x=[] #days
y=[] #probanilities
#init sum for expetation
#for loop over sample space
for i in range(1, 32):
# P(i) * i
x.append(i)
y.append((1 - p)**(i - 1) * p)
print(x,y)
plt.plot(x,y, 'o')
plt.xlabel('Days')
plt.ylabel('Probability of the first snow')
plt.show()
In [3]:
from scipy.special import comb
# set parametrs
p = 0.3
N = 31
n=5
#binomial dist equation
days=[]
prob=[]
for i in range(1,N+1):
days.append(i)
prob.append(comb(N, i) * (1 - p)**(N - i) * p**(i))
print('The probability that is will rain 5 days out 31 is:',prob[4], N*p)
plt.plot(days,prob, 'o')
plt.plot(N*p*(np.ones((10))),np.linspace(0,0.16, 10), 'r')
Out[3]:
In [4]:
#set parameters
import math
N=100
mu = 1/20*N
x =[]
prob=[]
#equation for Poisson
for person in range(1, N+1):
x.append(person)
prob.append(math.exp(-mu) * mu ** person/ (math.factorial(person)))
plt.plot(x,prob, 'o')
plt.show()
For the following problems, choose and state an appropriate distribution, write out its parameters based on the problem statement and then compute the requested quantity. Write the distribution information in Markdown/LaTeX and compute answers in Python. Use for
loops for computing expected value and prediction intervals. Do not use numpy
or the formulas given in lecture notes. Assume in all these examples that multiple trials are independent.
[2 points] Let's assume total solar eclipse happens in continental USA every 38 years. The Last total solar eclipse was in 2017 in USA. What is probability of total solar eclipse in continental USA in 2020? Remember to read the instruction above!!
[2 points] Let's assume Lyft drivers pick up clients at probability of 3% at any given time. What is the probability of a Lyft driver taking only 10 people of out 400 clients.
[2 points] In January, you applied to 50 jobs. The probability of getting an interview is 0.3 for in January. What is the probablity that you get 7 interviews that month? What is the expected value of this distribution?
[5 points] Bees disappearing at 23% according the USDA from 2013 to 2014. What is the probability of butterflies dying off in 50 years?
[4 points] On average you run with probability of 0.4 per day. What is the expected value of the days during which you run.
In [5]:
#set parameter
lamda = 1/38 # units of inverse years
time=2020-2017 #years
print('Probability of the total solar eclipse is ',lamda*np.exp(-lamda*time))
In [37]:
N=400
p=0.03
mu=N*p
x=10
print('The probablity of picking up 10 clients is: ', (np.exp(-mu)*mu**x)/math.factorial(x))
In [7]:
p=0.1
N=10
print('The probability of saying the letter correctly once within 10 tries is:',(1 - p)**(N- 1) * p)
In [8]:
p=0.3
n=7
N=50
print('The probability of getting 7 interviews out of 50 jobs applications is:',comb(N, n) * (1 - p)**(N - n) * p**(n))
In [9]:
p=0.4 #per year
N=7
print('The expected value of days during which you run is:', N*p)