Lets say we are rolling 2 dice of different sides. Example: Dice 1 has 128 sides and Dice 2 has 256 sides.

I created a 2D array of size 128X256 to bin the result of dice1,dice2 combination. If it is 0,0 I increment location 0. If it is 0,1 I increment location 1 and so on.

I also keep account of the average. Example if. it is 0,0 average is 0 & I keep track of how many times that average occurred. & if it is 0,1 average is 0.5 and so on.

With a single trial of N iterations, I got the following :

For the bins : Minimum value : 806 Maximum value : 60907 Mean : 1831.054688 Standard Deviation : 1356.090617 Median : 1541 Variance : 1838981.761

For the average: Min 0 Max 191 Mean 94.60301218 Std Dev 41.63474096 Median 95

How can I apply confidence interval on the above data?

For the average case I calculated Std Err (SE) as Std Dev/sqrt of N & then multiplied it with. z. score for 95% confidence interval (1.96)

& then specified my interval as 94.603 +- z*SE

Is this correct?

Also I did 30 such trials. Is the better way to take the mean of means of each of these samples & Then apply confidence interval on that?

My final goal is to distribute M items to each of those bins such that each bin corresponds to picking an item. Through the distribution, each item is supposed to be picked with a certain ratio. I was also thinking should I be applying confidence interval to that ratio?

Is applying z score for this case correct approach? Sorry about the long question - Its been years since I learned statistics in high school. Can't remember much :)

  • $\begingroup$ Any chance I can get some guidance? $\endgroup$ – Ryan Aug 23 '18 at 16:38
  • $\begingroup$ (a) For what parameter do you want a confidence interval? (b) It seems you're programming a simulation. Do you want a numerical CI for the specific case mentioned? Maybe a programming a simulation can help with that. Or do you want an analytic formula for the CI? Program can't give you that, but may give you intuition or clues. $\endgroup$ – BruceET Aug 24 '18 at 1:32

Comment continued: From what you said in your question, I'm totally guessing the following scenario: You imagine a game in which you are repeatedly rolling two fair dice, one is $D_1$ with 128 sides and the other is $D_2$ with 256 sides. So at the $i$th turn your score is $T_i,$ the total on the two dice. The game consists of $n = 30$ turns, and you want the total score $S = \sum_{i=1}^{30} T_i.$ Finally, you want a 95% confidence interval for that total score.

Analytically, you could find the mean and variance of the numbers on the two dice, add them to find the mean and variance per turn [that is $E(T_i)$ and $Var(T_i)$]. Then you can use those quantities to get $E(S)$ and $Var(S).$ By the Central Limit Theorem $S$ should be approximately normal, and you can use that fact to get an interval that contains the value of $S$ 95% of the time.

I'd be surprised if all of that is exactly right, but maybe you can use it to improve your question so that someone can figure out what you really want.

It is easy enough to simulate the scenario I described above, so I'll do that in R and show the result below. [With a 100,000 iterations you can expect about two significant digits of accuracy for the mean and SD.]

s = replicate(10^5, sum(sample(1:256,30,rep=T)+sample(1:128, 30, rep=T)))
summary(s); var(s);  sd(s)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   3616    5484    5788    5789    6095    7663 
[1] 205792.1
[1] 453.6432

The histogram shows the simulated scores and the best-fitting normal curve seems to show scores are nearly normal.

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.