1 Q1 (7 pts)

A box has coins HH, TT, and a fair coin (HT). One coin is chosen uniformly at random and flipped. Given the first flip is Head, what is the probability the next flip (same coin) is Head?

Solution (Bayes):

Let \(C\in\{\text{HH},\text{TT},\text{F}\}\), each with prior \(1/3\).
\(P(H\mid \text{HH})=1,\;P(H\mid \text{TT})=0,\;P(H\mid \text{F})=1/2\).

Posterior: \[ P(\text{HH}\mid H)=\frac{(1/3)\cdot 1}{(1/3)\cdot 1 + (1/3)\cdot (1/2)}=\frac{2}{3},\quad P(\text{F}\mid H)=\frac{1}{3}. \]

Therefore \[ P(\text{next }H\mid H)=\tfrac{2}{3}\cdot 1+\tfrac{1}{3}\cdot \tfrac{1}{2}=\tfrac{5}{6}. \]

ans_q1 <- 5/6
ans_q1
## [1] 0.8333333

2 Q2 (12 pts total)

We interpret the diagram as C — (A ∥ B) — D in series, with component reliabilities: \(P(C)=0.8,\;P(A)=0.95,\;P(B)=0.7,\;P(D)=0.9\).
The middle block is parallel: \(P(A\cup B)=1-(1-0.95)(1-0.7)=0.985\).

2.1 (a) (6 pts) Probability the system works

pC <- 0.8; pA <- 0.95; pB <- 0.7; pD <- 0.9
p_parallel <- 1 - (1 - pA)*(1 - pB)  # A || B
p_sys <- pC * p_parallel * pD
p_sys
## [1] 0.7092

So, \(P(\text{system works}) = 0.8 \times 0.985 \times 0.9 = 0.7092\).

2.2 (b) (6 pts) Given the system does not work, \(P(D \text{ fails } \mid \text{system fails})\)

Let \(q_S=1-p_{\text{sys}}\) and \(q_D=1-p_D=0.1\). Because series blocks are independent, if \(D\) fails, the system fails. Thus \[ P(D\text{ fails}\mid S\text{ fails}) =\frac{P(D\text{ fails}\cap S\text{ fails})}{P(S\text{ fails})} =\frac{P(D\text{ fails})}{q_S} =\frac{0.1}{1-0.7092}\approx 0.3439. \]

qS <- 1 - p_sys
ans_q2b <- (1 - pD)/qS
ans_q2b
## [1] 0.343879

3 Q3 (10 pts)

Four gardeners: Oliver (miss 0.3 ⇒ show 0.7), Walter (miss 0.1 ⇒ show 0.9), Tom (miss 0.2 ⇒ show 0.8), and Jerry who comes exactly when Tom comes. Assume independence among Oliver, Walter, Tom; Jerry mirrors Tom. Let \(X\) be the number who show up. Find \(f_X(x)\).

Let \(O\sim \text{Bern}(0.7)\), \(W\sim \text{Bern}(0.9)\), and a pair \(T_2\in\{0,2\}\) with \(P(T_2=2)=0.8\), \(P(T_2=0)=0.2\). Then \(X=O+W+T_2\).

pO <- 0.7; pW <- 0.9; pT2 <- 0.8  # prob of {Tom & Jerry both present}=2
# Distribution of O+W:
pS0 <- (1-pO)*(1-pW)
pS1 <- pO*(1-pW) + (1-pO)*pW
pS2 <- pO*pW
# Mix with T-pair:
pmf <- c(
  `0` = 0.2*pS0,
  `1` = 0.2*pS1,
  `2` = 0.2*pS2 + 0.8*pS0,
  `3` = 0.8*pS1,
  `4` = 0.8*pS2
)
pmf
##     0     1     2     3     4 
## 0.006 0.068 0.150 0.272 0.504
sum(pmf)
## [1] 1

Thus the pmf: - \(P(X=0)=0.006\)
- \(P(X=1)=0.068\)
- \(P(X=2)=0.150\)
- \(P(X=3)=0.272\)
- \(P(X=4)=0.504\)

4 Q4 (9 pts)

A discrete rv with pmf \(f(x)=\dfrac{c}{4^x}\) for \(x=0,1,2,\dots\)

4.1 (a) (5 pts) Find \(c\)

\[ 1=\sum_{x=0}^\infty \frac{c}{4^x}=c\sum_{x=0}^\infty \left(\frac{1}{4}\right)^x =c\cdot \frac{1}{1-1/4}=\frac{4}{3}c \ \Rightarrow\ c=\frac{3}{4}. \]

c_q4 <- 3/4
c_q4
## [1] 0.75

4.2 (b) (4 pts) Compute \(F(2.5)=P(X\le 2)\)

\[ F(2.5)=\sum_{x=0}^{2}\frac{3}{4\cdot 4^x} =\frac{3}{4}\left(1+\frac{1}{4}+\frac{1}{16}\right) =\frac{3}{4}\cdot \frac{21}{16} =\frac{63}{64}=0.984375. \]

F_2_5 <- (3/4)*(1 + 1/4 + 1/16)
F_2_5
## [1] 0.984375

5 Q5 (23 pts)

A continuous rv with pdf \(f(x)=c(x-1)\) for \(1\le x<3\), else \(0\).

5.1 (a) (4 pts) Find \(c\)

\[ 1=\int_{1}^{3} c(x-1)\,dx = c\cdot \frac{(x-1)^2}{2}\Big|_{1}^{3} = c\cdot \frac{4}{2}=2c\ \Rightarrow\ c=\tfrac{1}{2}. \]

c_q5 <- 1/2
c_q5
## [1] 0.5

5.2 (b) (4 pts) \(P(1\le X<2)\)

\[ P(1\le X<2)=\int_{1}^{2}\tfrac{1}{2}(x-1)\,dx =\tfrac{1}{2}\cdot \frac{(x-1)^2}{2}\Big|_{1}^{2} =\frac{1}{4}. \]

p_1_2 <- 1/4
p_1_2
## [1] 0.25

5.3 (c) (4 pts) \(F(x)\)

\[ F(x)= \begin{cases} 0, & x<1,\\\\ \displaystyle \int_{1}^{x}\tfrac{1}{2}(t-1)\,dt =\frac{(x-1)^2}{4}, & 1\le x<3,\\\\ 1, & x\ge 3. \end{cases} \]

5.4 (d) (4 pts) \(E[X]\)

\[ E[X]=\int_{1}^{3} x\cdot \tfrac{1}{2}(x-1)\,dx =\tfrac{1}{2}\int_{1}^{3} (x^{2}-x)\,dx =\tfrac{1}{2}\Big(\frac{x^{3}}{3}-\frac{x^{2}}{2}\Big)\Big|_{1}^{3} =\frac{7}{3}\approx 2.333333. \]

EX <- 7/3
EX
## [1] 2.333333

5.5 (e) (4 pts) \(\mathrm{Var}(X)\)

\[ E[X^{2}]=\tfrac{1}{2}\int_{1}^{3}(x^{3}-x^{2})\,dx =\tfrac{1}{2}\Big(\frac{x^{4}}{4}-\frac{x^{3}}{3}\Big)\Big|_{1}^{3} =\frac{17}{3}. \] \[ \mathrm{Var}(X)=E[X^{2}]-(E[X])^{2} =\frac{17}{3}-\Big(\frac{7}{3}\Big)^{2} =\frac{2}{9}\approx 0.222222. \]

VarX <- 2/9
c(EX=EX, VarX=VarX)
##        EX      VarX 
## 2.3333333 0.2222222

5.6 (f) (3 pts) If \(Y=5X-2\), compute \(\mathrm{Var}(Y)\)

\[ \mathrm{Var}(Y)=25\,\mathrm{Var}(X)=\frac{50}{9}\approx 5.555556. \]

VarY <- 25*VarX
VarY
## [1] 5.555556

6 Q6 (8 pts)

A 10-item multiple-choice test; each item has 4 options. The student can eliminate one wrong option and guesses among the remaining 3, so \(p=1/3\) for each item. Passing is \(\ge 8\) correct. Compute the probability of passing.

Let \(X\sim\text{Binomial}(n=10,p=1/3)\). \[ P(X\ge 8)=\sum_{k=8}^{10} \binom{10}{k}\Big(\frac{1}{3}\Big)^k\Big(\frac{2}{3}\Big)^{10-k} =\frac{201}{3^{10}}\approx 0.003406. \]

n <- 10; p <- 1/3
ans_q6 <- pbinom(7, size=n, prob=p, lower.tail = FALSE)
c(exact_fraction = "201 / 3^10", numeric = ans_q6)
##        exact_fraction               numeric 
##          "201 / 3^10" "0.00340395264949449"

7 Q7 (12 pts)

There are 8 dogs and 6 cats (total 14). Four pets are chosen without replacement.

Let \(X\) = number of dogs chosen. Then \(X\sim \text{Hypergeometric}(N=14,K=8,n=4)\): \[ P(X=k)=\frac{\binom{8}{k}\binom{6}{4-k}}{\binom{14}{4}}, \quad k=0,1,2,3,4, \] with \(\binom{14}{4}=1001\).

7.1 (a) (4 pts) Probability distribution of \(X\)

N <- 14; K <- 8; n <- 4
den <- choose(14,4)
k <- 0:4
pmf_q7 <- choose(8,k)*choose(6,4-k)/den
data.frame(k, P=pmf_q7)
##   k          P
## 1 0 0.01498501
## 2 1 0.15984016
## 3 2 0.41958042
## 4 3 0.33566434
## 5 4 0.06993007

Values: - \(P(0)=15/1001\)
- \(P(1)=160/1001\)
- \(P(2)=420/1001\)
- \(P(3)=336/1001\)
- \(P(4)=70/1001\)

7.2 (b) (4 pts) \(P(\text{at least one dog})=1-P(0)=1-15/1001=986/1001\approx 0.985\).

p_atleast1 <- 1 - pmf_q7[1]
p_atleast1
## [1] 0.985015

7.3 (c) (4 pts) \(E[X]=n\cdot \dfrac{K}{N}=4\cdot \dfrac{8}{14}=\dfrac{16}{7}\approx 2.285714\).

EX_q7 <- n*(K/N)
EX_q7
## [1] 2.285714

8 Q8 (11 pts)

Three identical fair coins are tossed simultaneously until all three show the same face (HHH or TTT). Each trial succeeds with \(p=2/8=1/4\).

Let \(T\) be the number of tosses (trials) until first success; \(T\sim\text{Geometric}(p=1/4)\) with support \(\{1,2,\dots\}\).

8.1 (a) (6 pts) \(P(T>3)=(1-p)^3=(3/4)^3=27/64\approx 0.421875\).

p <- 1/4
P_more_than_3 <- (1-p)^3
P_more_than_3
## [1] 0.421875

8.2 (b) (5 pts) \(E[T]=1/p=4\).

E_T <- 1/p
E_T
## [1] 4

9 Q9 (8 pts)

Let \(X_1,X_2,X_3 \overset{iid}{\sim}\text{Exp}(\beta=6)\) (scale). Find \(P(\text{at least one }X_i>8)\).

For \(\text{Exp}(\beta)\), \(F(x)=1-e^{-x/\beta}\) for \(x>0\).

\[ P\Big(\max_i X_i>8\Big)=1-P(X_1\le 8, X_2\le 8, X_3\le 8) =1-\left(1-e^{-8/6}\right)^3. \]

beta <- 6; x <- 8
ans_q9_exact <- 1 - (1 - exp(-x/beta))^3
c(numeric = ans_q9_exact)
##   numeric 
## 0.6006567

Numerically, \(e^{-8/6}\approx 0.2636\), so the probability is about 0.601.