User blog:Guy Bukzi Montag/Drop Rates Explained: 5th Anniversary (III)

This is part III of a series on the maths behind drop rates.


 * Part I: Practical questions
 * Part II: Extracting probabilities
 * Part III: More than one box
 * Part IV: The Asphalt 8 Box Calculator (tba)

This part continues the explanations of part II and will show you how to calculate your chances if you open more than one box. The 5th Anniversary boxes will serve as examples, but the methods also work for other boxes.

Introduction

 * "I need 2 more blueprints to assemble my SLK 55 SE. If I buy a Specialist Bundle, my chance of getting a blueprint is 10 %. I have 4,825 coins, so I can buy 32 bundles. Will that be enough to get my 2 missing blueprints?"

To answer this question, it's reasonable to start with fewer boxes:

One box
If you buy one box, there are only two possibilities: either you get a blueprint or not.
 * Your chance of getting a blueprint is $$\tfrac{1}{10}$$,
 * and $$\tfrac{9}{10}$$ of getting none.

Two boxes
Buying two boxes already offers four possibilities, each with its own probability:
 * blueprint in the first one: $$\tfrac{1}{10}$$
 * blueprint also in the second one: $$\tfrac{1}{10} \cdot \tfrac{1}{10} = \tfrac{1}{100}$$
 * no blueprint in the second one: $$\tfrac{1}{10} \cdot \tfrac{9}{10} = \tfrac{9}{100}$$
 * no blueprint in the first one: $$\tfrac{9}{10}$$.
 * blueprint in the second one: $$\tfrac{9}{10} \cdot \tfrac{1}{10} = \tfrac{9}{100}$$.
 * no blueprint also in the second one: $$\tfrac{9}{10} \cdot \tfrac{9}{10} = \tfrac{81}{100}$$.

As you need 2 blueprints, only the first of the four combinations is successful and has a probability of $$\tfrac{1}{100}$$ = 1 %. A chance of 1 % is not very satisfying, but we now know how to find the values for three boxes.

Three boxes
In the following table, "B" stands for blueprint, "0" for no blueprint and P for the probablity of the combination. Successful combinations with at least two blueprints are highlighted:

As you see, there's more than one way to get two blueprints: You can get them from the first and second, second and third or from the first and third box. And there's also the possibility of getting even three blueprints, so 4 out of 8 sequences are successful.

The probability of getting at least 2 blueprints from 3 boxes is


 * $$\frac{9}{1000} + \frac{9}{1000} + \frac{9}{1000} + \frac{1}{1000} = \frac{28}{1000} = 2.8 %$$.

If you never buy more than three boxes, you can stop here. You can make a small table, multiply the probabilities and sum up the successful sequences. But that's not realistic as events like the 5th Anniversary grant a lot more than three boxes.

Permutation
And that's where the problem starts: Technically you have been examining all possible ways of drawing 3 elements from 2, with repetition (you put pack what you have drawn, because a 0 or a B can appear several times), and where order matters (because 0-0-B is not the same as B-0-0). In combinatorics, this is called a permutation with repetition.

Unfortunately, those permutations have the nasty habit to generate extremely large numbers. If you draw once, you have only two possibilities: 0 and b. The second draw (box) adds two more possibilities to every existing one, so you get $$2 \cdot 2 = 2^2 = 4$$ possibilities, then $$2 \cdot 2 \cdot 2 = 2^3 = 8$$ and so on. Ten boxes would already generate a table with $$2^{10} = 1,024$$ rows, so counting manually all successful combinations becomes impossible with increasing numbers of draws (boxes).

But now we know how to calculate the total number of possibilities:


 * Buying $$n$$ boxes granting 1 random item generates $$2^n$$ possibilities.

For our SLK 55 SE example, this means: If you buy 32 boxes, you get $$2^{32} = 4,294,967,296$$ possible sequences.

Combination
Now we have to find all those of our $$2^n$$ sequences that contain at least the desired number $$d$$ of desired blueprints.

In our example table with 3 boxes and 2 desired blueprints ($$n= 3, d = 2$$) we had $$2^3 = 8$$ sequences of which 4 were successful. How can we calculate the 4 successful ones? Let's have a closer look at them:


 * The three sequences 0-B-B, B-B-0 and B-0-B have in common that they are arrangements of 2 blueprints in a set of 3 items.
 * The fourth sequence consists of 3 blueprints in a set of 3 items: B-B-B.

Note that this time the order of the Bs doesn't matter: blueprint is blueprint. For example, there is no distinction between a possible B1-B2-B3 and B1-B3-B2. They are all treated as one sequence B-B-B, so there is only one way to arrange 3 blueprints in a set of 3 items.

In mathematics, the selection of $$k$$ items from a set with $$n$$ elements, such that the order of selection doesn't matter, is called a combination and is denoted by $$\tbinom nk$$ (read as "n choose k"). If you have a scientific calculator and wondered what the nCr button does: Read it as "n choose r" and you can do the calculations in this chapter by yourself!

$$\tbinom nk$$ is called a binomial coefficient and can be calculated as follows:


 * $$ \binom nk = \frac{n!}{k!(n-k)!}$$

For our example with three boxes this means that the number of different combinations of 2 blueprints in a set of 3 is:


 * $$ \binom 32 = \frac{3!}{2!(3-2)!} = \frac{6}{2 \cdot 1} = 3$$

And the number of different combinations of 3 blueprints in a set of 3 is:


 * $$ \binom 33 = \frac{3!}{3!(3-3)!} = \frac{6}{6 \cdot 1} = 1$$

If we add these two results, we have exactly the number of successful sequences found in the table (4).

For other examples, the term "if we add" has to be a little bit more specific: We have to add all binomial coefficients starting with $$k = d$$ ($$d$$ being the number of desired blueprints), then $$k = d + 1$$, $$k = d + 2$$, ... up to $$k = n$$ (because we can get more than the 2 desired blueprints up to the possibility of getting a blueprint in each of the $$n$$ boxes).

So generally the number of possible combinations $$c$$ of at least $$d$$ desired items in $$n$$ boxes is the sum of the binomial coefficients with $$k = d$$, $$k = d + 1$$, $$k = d + 2$$, ... to $$k = n$$:


 * $$c = \sum_{k = d}^n \binom{n}{k}$$

Now we can use this formula for the SLK 55 SE blueprints: We have $$n = 32$$ boxes and want $$d = 2$$ blueprints, so the number $$c$$ of combinations containing at least 2 blueprints is


 * $$c = \sum_{k = 2}^{32} \binom{32}{k} = \binom{32}{2} + \binom{32}{3} + \binom{32}{4} + ... + \binom{32}{32} = 4,294,967,263$$.

If you want to use your scientific calculator, you have to calculate each binomial coefficient from $$k = 2$$ to $$k = 32$$ with the nCr button and build the sum of all the results.

Probability
Now we are very close to what we wanted to have: the probability of all those combinations with at least 2 blueprints. Let's go back to the above table for 2 blueprints from 3 boxes: The probability for the sequence B-B-0, for example, was $$\tfrac{1}{10} \cdot \tfrac{1}{10} \cdot \tfrac{9}{10} = \tfrac{9}{1000}$$.

If the probability for an event $$B$$ (getting a blueprint) is $$\tfrac{1}{10}$$, the probability of the complementary event $$\bar B$$ (not getting one) is


 * $$P(\bar B) = 1 - P(B)$$,

thus $$1 - \tfrac{1}{10} = \tfrac{9}{10}$$.

If $$d$$ is the number of desired blueprints, then what we did in the table was multiplying $$d$$ times the probability of $$B$$: $$\tfrac{1}{10} \cdot \tfrac{1}{10} = (\tfrac{1}{10})^2$$. We did the same with $$\bar B$$, but it's not that evident, because in a set of 3, there is only 1 event $$\bar B$$ left: $$\tfrac{9}{10} = (\tfrac{9}{10})^1$$. The product of these two values was the final propability of the sequence:


 * $$\left ( \frac{1}{10} \right )^2 \cdot \left ( \frac{9}{10} \right )^1 = \frac{1}{10} \cdot \frac{1}{10} \cdot \frac{9}{10} = \frac{9}{1000}$$

Generally said, the probability of one combination in the table is


 * $$(P(B))^d \cdot (P(\bar B))^{n-d} = (P(B))^d \cdot (1 - P(B))^{n-d}$$,

where
 * $$d$$ is the number of desired blueprints,
 * $$n$$ the number of boxes,
 * $$P(B)$$ the probability of getting a blueprint.

As all combinations of 2 Bs in a set of 3 (B-B-0, 0-B-B and B-0-B) have the same probability, we can multiply this probability with the number $$c$$ of possible combinations to obtain the total probability of all combinations of 2 blueprints in a set of 3. Fortunately, we already know that $$c$$ is the binomial coefficient $$\binom32$$, so we get


 * $$ \left ( \frac{1}{10} \right )^2 \cdot \left ( \frac{9}{10} \right )^1 \cdot \binom32 = \frac{9}{1000} \cdot 3 = \frac{27}{1000} = 2.7 %$$.

Analogously, the probability for 3 blueprints in a set of 3 is


 * $$ \left ( \frac{1}{10} \right )^3 \cdot \left ( \frac{9}{10} \right )^0 \cdot \binom33 = \frac{1}{1000} \cdot 1 = \frac{1}{1000} = 0.1 %$$.

To get the total probability of at least 2 blueprints in a set of 3, we add these probabilities and get exactly the 2.8 % from our table above.

So generally the probability $$P_{n,d}$$ of getting at least $$d$$ desired items from $$n$$ boxes is as follows:


 * $$\sum_{k = d}^n (P(B))^k \cdot (1 - P(B))^{n-k} \cdot \binom{n}{k}$$,

where $$P(B)$$ is the probability of getting the item.

With this formula we are able to answer the question of the beginning: We have $$n = 32$$ boxes and want $$d = 2$$ blueprints of which each has a probability of $$P(B) = \tfrac{1}{10}$$, so the probability of getting at least 2 blueprints from these boxes is



\begin{align} &\sum_{k = 2}^{32} \left (\frac{1}{10} \right )^k \cdot \left (1 - \frac{1}{10} \right )^{32-k} \cdot \binom{32}{k}\\ \\ \\ &= \left (\frac{1}{10} \right )^2 \cdot \left (\frac{9}{10} \right )^{30} \cdot \binom{32}{2} + \left (\frac{1}{10} \right )^3 \cdot \left (\frac{9}{10} \right )^{29} \cdot \binom{32}{3} + ... +\left (\frac{1}{10} \right )^{32} \cdot \left (\frac{9}{10} \right )^{0} \cdot \binom{32}{32}\\ \\ \\ &= 84.36 %. \end{align} $$

Did I calculate this manually? Definitely not. I wrote a few functions for this which I'll share with you in my next post.

If you have questions or find mistakes: Feel free to comment!