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
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\).
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\).
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
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\)
A discrete rv with pmf \(f(x)=\dfrac{c}{4^x}\) for \(x=0,1,2,\dots\)
\[ 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
\[ 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
A continuous rv with pdf \(f(x)=c(x-1)\) for \(1\le x<3\), else \(0\).
\[ 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
\[ 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
\[ 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} \]
\[ 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
\[ 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
\[ \mathrm{Var}(Y)=25\,\mathrm{Var}(X)=\frac{50}{9}\approx 5.555556. \]
VarY <- 25*VarX
VarY
## [1] 5.555556
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"
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\).
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\)
p_atleast1 <- 1 - pmf_q7[1]
p_atleast1
## [1] 0.985015
EX_q7 <- n*(K/N)
EX_q7
## [1] 2.285714
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\}\).
p <- 1/4
P_more_than_3 <- (1-p)^3
P_more_than_3
## [1] 0.421875
E_T <- 1/p
E_T
## [1] 4
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.