Homework 6

CHE 116: Numerical Methods and Statistics

2/22/2018


1. Review Questions (10 Points)

  1. [1 point] A probability mass function must give a positive number for each element in the sample space and $\underline{\hspace{0.5in}}$?

  2. [1 point] Which of these are invalid sample spaces and which are valid: $\{1,3,-2\}$, $\{A, B\}$, $\{\textrm{Ace of hearts}, \textrm{king of diamonds}\}$, all real numbers.

  3. [1 point] What rule allows me to rewrite $P(x \,|\,y)P(y)$ as $P(x, y)$?

  4. [2 points] If there is a 10% chance of rain for 3 days in a row, what's the probability of there being rain at least once within those days?

  5. [2 points] Harry says that expected value is like an average, so you can compute two ways: $ E[X] = \sum_i^N \frac{x_i}{N} $ and the way we learned in class: $E[X] = \sum_i P(x) \cdot x$. Is Harry correct or is there an issue with his logic?

  6. [1 point] How many elements will I have in my list if I create it using list(range(5,8))?

  7. [2 points] In the binomial distribution, we only consider number of successes. Let's try considering each permutation as unique. For example, if $N = 3$ and $n = 1$, you could have $100$, $010$, and $001$. If $N = 10$, how many unique permutations are possible for all numbers of successes? Review your HW 5, questions 1.2-1.5.

2. Marginal Probability Review (19 Points)

You are a baby being carried in a stork to your parents. Your parents live in either:

  1. USA (u, 320)
  2. China (c, 1300)
  3. Germany (g, 80)

The probability of your birth location is proportional to the populations. As a baby, you are concerned with your career options, which are

  1. Rock star (r)
  2. Professor (p)
  3. Doctor (d)

Answer the following using $B$ as the random variable for birthplace and $J$ as the random variable for job. We have the following information:

$$P(J = r \,|\, B = c) = 0.05$$$$P(J = d \,|\, B = c) = 0.5$$$$P(J = r \,|\, B = u) = 0.8$$$$P(J = p\,|\, B = u) = 0.01$$$$P(J = p\,|\, B = g) = 0.75$$$$P(J = d \,|\, B = g) = 0.2$$
  1. [2 point] Write out the missing conditionals and marginal probabilities.
  2. [4 points] What is the probability that you will be a professor?
  3. [3 points] What is the probability that you will be a rock star born in China?
  4. [2 point] You were born in Germany. What's the probability of becoming a doctor?
  5. [4 points] Consider the random variable $Z$, which indicates if you are a doctor or rockstar (true for $J=d$ and $J=r$). What is $P(Z = 1 \,|\, B=u)$?
  6. [4 points] What is $P(B=g \,|\, Z = 0)$? Find a way to re-use the calculation you did in 2.2 to help

3. Plotting Probability Distributions (18 Points)

Label your axes, add a title, and use LaTeX in your labels when necessary. Use dots connected by lines for discrete and lines for continuous.

  1. [6 points] Plot three different parameter of the geometric distribution: $p = 0.2, p = 0.5, p = 0.8$. Add vertical lines at their means. Extra credit: accomplish the plot of the three lines using a for loop.

  2. [4 points] Plot the binomial distribution for $N = 25, p = 0.7$. Recall that the Poisson is an approximation to the Binomial. Plot the Poisson approximation to this Binomial distribution on the same plot.

  3. [2 points] Make a second plot with the binomial and Poisson, but use $N = 25, p = 0.10$. How good is the approximation?

  4. [6 points] The command plt.fill_between can be used to plot an area under a curve. For example, fill_between(x, 0, y) will fill the area between 0 and y, where y could be a numpy array. Using fill_between, show the cumulative probability function for the exponential distribution from $t = 0$ to $t = 5$ with $\lambda = 0.25$. Ensure that there are two lines on your plot: one that is the exponential pdf and one that is the fill_between. The pdf should extend further than your fill_between line. Add a vertical line at $t=5$. No legend necessary.

4. Prediction Intervals and Loops (19 Points + 12 EC)

  1. [1 point] "The 95% prediction interval for a geometric probability distribution" can be described with what mathematical equation? Answer as a $\LaTeX$ equation.

  2. [6 points] Using a for loop, compute a lower (starting at 0) 90% prediction interval for the binomial distribution with $N = 12, p = 0.3$.

  3. [6 points] Using a for loop, compute an upper (ending at N) 95% prediction interval for the binomial distribution with $N = 20, p = 0.6$.

  4. [6 points] Using a for loop, compute a 80% prediction interval for the geomemtric distribution for $p = 0.02$. Just pick a large number for the upper-bound of the for loop.

  5. [12 Extra Credit Points]. Repeat 4.3 using a while loop.

5. Normal Distribution (8 Points)

Use scipy.stats here as needed. Except for 5.1 and 5.3, answer in Python.

  1. [2 points] In the $Z$-score equation $ Z = (x - \mu) / \sigma$, what is $x$?
  2. [1 point] What is $P(x < -2)$ for a standard normal distribution?
  3. [1 point] What is $P(x > 2)$ for a standard normal distribution? Use your knowledge of probability expression, not scipy.stats to answer this one.
  4. [2 points] Given that $\mu = 2$, $\sigma = 1.2$, what is the probability of observing a sample between -2 and 0? Answer using a $Z$-score.

  5. [2 points] Given that $\mu = 2$, $\sigma = 1.2$, what is the probability of observing a sample between -2 and 0? Answer without using a $Z$-score.

6. Sentiment (6 Points)

Answer in 1-2 sentences. No correct answer, just give an honest, meaningful answer to receive credit.

  1. Why is probability important to know as a chemical engineer?

  2. Do you feel confident in understanding probability expressions, like conditionals and marginals?

  3. Can you imagine yourself using Python in your fluid mechanics or other courses?

  4. What topic are you most confident in?

  5. Do you have any feedback for the course?