Probability distributions - Your turn#
Note
Click the and open this notebook in Colab to enable interactivity.
Note
To save your progress, make a copy of this notebook in Colab File > Save a copy in Drive
and you’ll find it in My Drive > Colab Notebooks
.
Note this exercise has four parts!
Part (a)#
You work for a VC firm, pitching ideas to different investors every day. While snooping around a rival’s office, you find a report he’s written to management bragging that he has only a \(15\%\) chance of missing his sales target this year. Assuming that you know his success rate is \(30\%\), and assuming that you model his sales with a binomial distribution with \(365\) trials, what is his sales target?
# TODO: Write your code below
Part (b)#
Your zero-\(g\)-proof-pen manufacturing company is in dire straights, and you want to know what the probability is that you will have to declare bankruptcy. In order to stay afloat, you need the following three things to happen:
Your factory needs to fill an order for \(500\) pens without making any defective pens (assume a binomial distribution with a \(0.05\%\) chance of error).
You also need a space shuttle to be launched in the next month (consider space shuttle launch per month a Poisson random variable with rate \(0.4\), and you need exactly 1 launch).
You need your CEO to find at least 3 NASA secretaries who will take his phone calls (in the past this occurrence has been normally distributed with mean \(2.6\) and variance \(1\)).
Assuming that these three events are independent, what is the probability that your company will go under?
# TODO: Write your code below
Part (c)#
Write a Monte Carlo simulation to test your analytical result in part (b), using the distribution.rvs()
function with the appropriate parameters.
Vary the number of trials from \(100\) to \(100000\) (in steps of ~\(10,000\)) and report the error in the computed probability.
# TODO: Write your code below
Part (d)#
Write a script to simulate a sampling procedure from \(1,000\) identical lots using the binominal distribution with probability of a part being defective of \(0.01\). Create a histogram showing the frequencies of the number of observed defective parts in \(1,000\) lots using \(10,000\) trials. On the same set of axes plot the scaled probability density function for the binominal distribution with the appropriate parameters. The density function can be plotted over the range from \(0\) to \(25\). Compare the empirical and the theoretical distributions.
# TODO: Write your code below
Exporting your work#
When you’re ready, the easiest way to export the notebook is to File > Print
it and save it as a PDF.
Remove any excessively long, unrelated outputs first by clicking the arrow → next to the output box and then Show/hide output
.
Obviously don’t obscure any necessary output or graphs!