User:Markkawika/Mathfoo

WoW
If a WoW mob drops a desired item with a drop rate of $$N$$ (a real number between $$0.0$$ and $$1.0$$, how many runs, on average, must a player make before he sees the given item drop?

First, we must establish that this is a short-circuiting procedure. In other words, as soon as the player sees the item drop, he stops trying to get the item (this assumes, of course, that the player wins the roll for the item). This means it makes more sense to calculate the failure chance than the success chance of an item dropping.

The math for this is easy. If the drop rate is $$N$$, then the failure chance in one run is $$1.0 - N$$. Thus, the failure rate after $$R$$ runs is:


 * $$(1.0 - N)^R$$

Thus the chance of successfully seeing the desired item drop after $$R$$ runs is:


 * $$1.0 - (1.0 - N)^R$$

But we want to know the average number of runs a player will have to make before seeing the item drop. Thus, we want to know what value of $$R$$ will get the success rate to at least 0.5 (50%). We need to solve the following equation for $$R$$:


 * $$\begin{matrix}

1.0 - (1.0 - N)^R & = & 0.5 \\ (1.0 - N)^R - 1.0 & = & -0.5 \\ (1.0 - N)^R & = & 0.5 \\ R \ln(1.0 - N) & = & \ln(0.5) \\ R & = & \frac{\ln(0.5)}{\ln(1.0 - N)} \end{matrix}$$

This tells us what exact number R must be to get the chances of success to exactly 0.5. This isn't reasonable, though, because R is a real number and we can only make an integer number of runs (how do you run Baron 6.973 times?). Thus, we must take the ceiling of the right-hand-side to tell us the average number of times a player must kill a mob in order to see a given item drop.

This gives us our final answer:


 * $$R = \left \lceil \frac{\ln(0.5)}{\ln(1.0-N)} \right \rceil $$

Thorkran
More fun:

What's the likelihood that, using a d20, you will roll a 1-4, followed by a natural 20, after N rounds? The formula is given by P(N), where N is the number of rounds, and P(N) is the likelihood that it has occurred after N rounds.


 * $$\begin{matrix}

P(1) & = & 0.0 \\ P(N) & = & P(N-1) + \sum_{i=0}^{N-2}0.2 \cdot 0.05 \cdot 0.8^i \cdot 0.95^{N-2-i} \end{matrix}$$

Carrying out the calculation, then (23-Oct-2018, when I have no idea why I wanted to know at the time):


 * $$\begin{matrix}

P(1) & = & 0.000000 \\ P(2) & = & 0.010000 \\ P(3) & = & 0.027500 \\ P(4) & = & 0.050525 \\ P(5) & = & 0.077519 \\ P(6) & = & 0.107259 \\ P(7) & = & 0.138789 \\ P(8) & = & 0.171363 \\ P(9) & = & 0.204407 \\ P(10) & = & 0.237475 \\ P(11) & = & 0.270233 \\ P(12) & = & 0.302426 \\ P(13) & = & 0.333869 \\ P(14) & = & 0.364427 \\ P(15) & = & 0.394006 \\ P(16) & = & 0.422547 \\ P(17) & = & 0.450012 \\ P(18) & = & 0.476386 \\ P(19) & = & 0.501666 \end{matrix}$$

Therefore, on average, it will take Thorkran 19 rounds before he rolls a 1-4 on a d20 followed by a crit. I don't know why I needed to know that, but now, finally, I have the answer.

In fact, this generalizes to any "roll &lt;this&gt; after &lt;that&gt;" question.

If $$Pa$$ is the probability of the first thing happening (and $$1-Pa$$ is the probability it will not happen), and $$Pb$$ is the probability of the second thing happening, then the probability $$P(N)$$, after $$N$$ rounds, of the first thing happening at some point, followed by the second thing happening, is:


 * $$\begin{matrix}

P(1) & = & 0.0 \\ P(N) & = & P(N-1) + \sum_{i=0}^{N-2}Pa \cdot Pb \cdot (1-Pa)^i \cdot (1-Pb)^{N-2-i} \end{matrix}$$