How to calculate confidence interval for dice hits?

1k Views Asked by At

There is a dice with $e$ edges $\left[1;e\right]$. The dice rolls in a one experiment $r$ times. Thus the edge numbered $1$ can be generated in this experiment from $0$ to $r$ times. I need to calculate theoretical 95% confidence interval for this count.

Here is my solution but I get wrong result.
For example if $edges=3$, $rolls=1000$, I get $\left[332;334\right]$.
What did I do wrong?


$E\left(e,1\right) = \frac{1}{e}$

$Var(e,1) = \left[\frac{1}{r} \cdot \left(\left(1 - E\left(e,1\right)\right)^2\right)\right] + \left[\frac{\left(r-1\right)}{r} \cdot \left(\left(0 - E\left(e,1\right)\right)^2\right)\right]$

$Var(e,r) = r \cdot Var(e,1)$

$\sigma\left(e,r\right)=\sqrt{Var\left(e,r\right)}$


$a\left(e,r,h\right) = 1.96 \cdot \frac{\sigma\left(e,h\right)}{\sqrt{r}}$

$b\left(e,r,h\right) = 1.96 \cdot \frac{\sigma\left(e,h\right)}{\sqrt{r}}$


$e: \text{edges}$
$r: \text{rolls}$
$h: \text{hits}$

1

There are 1 best solutions below

0
On BEST ANSWER

It appears that you want what is called a prediction interval (PI, not "confidence interval") for $N_r$, where the random variable $N_r$ is the total number of rolls that produce a $1$ (out of $r$ rolls). Now $N_r= X_1+...+X_r$, where $$X_i = \begin{cases} 1, & \text{ if the ith roll is a } 1 \\ 0, & \text{ otherwise} \end{cases}$$

and we have the normal approximation when $r$ is sufficiently large:

$$N_r = \text{Binomial}(r,p) \approx \text{Normal}(\mu, \sigma^2)$$

where $$\\ \mu = E[N_r]=rp\\ \sigma^2= V[N_r]=rp(1-p)\\ p=P[X_i=1]=1/e$$ ($e$ being the number of sides on the die, which is assumed to be "fair").

NB: $$\begin{align}E[X_i] &= P[X_i=1]\ 1 + P[X_i=0]\ 0\\ &= p\ 1 + (1-p)\ 0\\ &= p\\ \\ V[X_i] &= P[X_i=1](1-E[X_i])^2 + P[X_i=0](0-E[X_i])^2\\ &= p(1-p)^2 + (1-p)(0-p)^2\\ &= p(1-p)\\ \\ E[N_r] &= E[X_1+...+X_r]\\ &= r\ E[X_1]\\ &= r\ p\\ \\ V[N_r]&=V[X_1+...+X_r]\\ &= V[X_1]+...+V[X_r]\quad\text{because these are independent}\\ &= r\ V[X_1]\\ &= r\ p(1-p)\\ \end{align} $$

An approximate $95\%$ PI for $N_r$ is then $$\mu\ \pm\ 1.96\sigma, $$ because $$P[\mu - 1.96\sigma < N_r < \mu + 1.96\sigma] \approx 0.95. $$ For your example, $e=3,\ r = 1000:\ \ \mu\ \pm\ 1.96\sigma = 333.3\ \pm\ 29.2 \approx [304,363]$.