1
$\begingroup$

I'm a game developer trying to set up some random distributions to produce a desired range of possible outcomes, but am getting confused about margins of error when it comes to unlikely events. Probably a simple question for a statistics expert.

For simplicity, say the game has 20 crates, each of which contains a random reward when the player opens it. If the probability of reward A is 50%:

$$P(A) = 0.5$$

Then the expected value would be 10 rewards total (not sure if I'm using the notation right, correct me if not):

$$E(A) = 20\cdot0.5 = 10$$

On different playthroughs, assuming a $2\sigma$ 95% confidence interval, you're likely to get between about 6 and 14 reward A's 95% of the time:

$$\sigma = \sqrt(0.25\cdot20)\approx2.24$$ $$E(A)+2\sigma=14.48$$ $$E(A)-2\sigma=5.52$$

Running random simulations bears that out, the results match the distribution. What I'm confused about is if reward B is rare, say:

$$P(B) = 0.01$$ $$E(B) = 0.2$$

Then the above math doesn't seem to fit:

$$\sigma \approx 2.24$$ $$E(B)+2\sigma=5.48$$ $$E(B)-2\sigma=-3.48 = 0$$

The likelihood of actually getting 5 reward B's on one playthrough, with an only 1% chance per container, would seem to be way less than 5%, so there must be some scale factor here than I'm missing that correlates the +/- margin of error with the actual probability of the event.

If anyone knows what I'm missing let me know!

$\endgroup$
2
$\begingroup$

If the probability is $p$ that a crate contains a reward, and the crates are filled independently, then the number of rewards seen in $n$ crates has a binomial $(n,p)$ distribution so the expected number of rewards is $\mu:=np$ and the standard deviation is $\sigma:=\sqrt{np(1-p)}$. When $n=20$ and $p=.01$ this yields $\mu=0.2$ and $\sigma\approx 0.445$ so you are not likely to see more than one $B$ reward in twenty crates. Your error was in calculating $\sigma$ for reward $B$; you were assuming $p=1/2$ in your calculation, when it should have been $p=.01$.

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ Thanks! I wasn't aware of the origin of that 0.25 in the variance calculation, knowing it comes from $p(1-p)$ is super helpful. $\endgroup$ – QuadrupleA May 18 '16 at 23:25

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.