Homework
Homework
1. From the probability p of free beer in §1.2, we can also estimate π, because the relation
p = π/4 implies π = 4 × p.
(a) For sample size (or replications) n = 100, find 95% confidence interval and the mean
for pi estimation.
(b) Repeat (a) for sample size n = 500, 1000, 5000;
(c) Plot mean, and confidence interval against n. Is the width of the interval increasing or
decreasing as n increases?
Hints :
For sample size n = 100, we first generate the sample/simulation as in the dart game §1.2. Then
we add another column “pi” for 4 ∗ p. From the column ’pi’, we can compute the statistics: mean,
and 95% confidence interval (LB, UB). Repeat the above procedure for sample size n = 500,
1000, 5000, and find the associated statistics (mean, LB, UB). Now we can put these data into a
table, with four columns n, mean, LB, UB. Use the first-column n as x-axis, and other columns
as y-axis, we can plot the desired results.
2. Sam and Mary are salespeople. Sam’s weekly sales X is uniformly distributed: X ∼ U[1,
5] (in thousands of dollars). Mary’s sales Y follows normal distribution with mean μ = 3
and standard deviation σ = 1.3: Y ∼ N (3, 1.32). Each week they compare their
performance by the ratio X/Y . If ratio X/Y < 0.3, Sam buys the dinner; if ratio X/Y > 0.7,
Mary buys; otherwise, they split the check. Assume sample size N = 1000 weeks.
(a) Compute and plot the distribution (histogram) of the dinner outcome; i.e., how often
will Sam buy the dinner, how often will Mary buy, and how often will they split?
(b) Is this deal fair?
Hints :
The key random variables are X ∼ U[a, b] and Y ∼ N (μ, σ 2). Let ratio = X/Y , a = 1, and
b = 5.
In Excel, week = SEQUENCE(1000)
X = a + (b – a) ∗ RAND()
Y = NORM.INV(RAND(), mu, sigma)
ratio = X/Y
Depending on ratio, for each week, we have three events (outcomes) Ai, i = 1, 2, 3:
A1 = { Sam buys } = (ratio < 0.3)
A2 = { Mary buys } = (ratio > 0.7)
A3 = { Split } = (ratio >= 0.3) ∗ (ratio <= 0.7).
The three events are mutually exhaustive and jointly exhaustive. They can be modeled
by three Bernoulli random variables (indicators). In Excel, we use three columns to store
the three indicators; e.g., 1A1 = IF(ratio < 0.3, 1, 0) = 1 ∗ (ratio < 0.3). Alternatively, we
can model the outcomes (realizations) by a random variable V with three values:
3. generate random variables: Normal(mu=7, sigma=3), Binomial(n = 10, p = 0.3)
from this question