User:Guy Bukzi Montag/sandbox

''Nothing to see here. It's only my playground for future blog posts.''

Everything on this page is a draft and will be deleted when the final post is published.

''If you do see something here, it's probably a blog post in the making. Feel free to comment, corrections are welcome!''

---

Drop Rates Explained: 5th Anniversary (IV)

This is part IV 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: Box inside a box
 * Part V: The Asphalt 8 Box Calculator (tba)

This part continues the explanations of part III and will show you how to calculate your chances if a box grants a variable amount of desired items.

Expectations revisited
In Part II we have examined the expected values of items in a box. Now it's time for the more precise definition that is used in probability theory, because numbers can have expected values, too.

Let $$X$$ be a random variable with a finite number of finite outcomes $$x_1$$, $$x_2$$, ..., $$x_k$$ occurring with probabilities $$p_1$$, $$p_2$$, ..., $$p_k$$, respectively. The expected value or expectation of $$X$$ is defined as


 * $$\operatorname{E}[X] = \sum_{i=1}^k x_i\, p_i = x_1p_1 + x_2p_2 + \ldots + x_kp_k$$.

Since all probabilities $$p_i$$ add up to 1 ($$p_1 + p_2 + \ldots + p_k = 1$$), the expected value is the weighted average, with $$p_i$$’s being the weights. In the special case of all probabilities being the same ($$p_1 = p_2 = \ldots = p_k$$), the weighted average turns into the simple average.

Example: If $$X$$ represents the outcome of a roll of a fair six-sided die, the possible values for $$X$$ are 1, 2, 3, 4, 5, and 6, all equally likely (each having the probability of $$\tfrac16$$). The expectation of $$X$$ is


 * $$\operatorname{E}[X] = 1\cdot\frac16 + 2\cdot\frac16 + 3\cdot\frac16 + 4\cdot\frac16 + 5\cdot\frac16 + 6\cdot\frac16 = 3.5$$.

In this case (all outcomes of $$X$$ have the same probability $$p$$), the general formula becomes


 * $$\operatorname{E}[X] = \sum_{i=1}^k x_i\, p = x_1p + x_2p + \ldots + x_kp$$.

The box inside the box
The "Elite Supplies" of the McLaren 720S World Tour and the "Expert Bundle" of the 5th Anniversary event have in common that they both contain guaranteed blueprints, but you don't know the exact number you'll get. For example, the Expert Bundle grants between 1 and 7 of them.

As resources are rare and an event usually offers several ways to spend them, it would be cool to know what we can expect before we take a decision. The most important questions are:


 * 1) How many blueprints can I expect?
 * 2) How probable is it that I get a certain number of blueprints?

How many blueprints can I expect?
In Part II I had introduced the "box inside the box" principle to isolate the random items that we wanted to examine. Now we do the same, but this time, we take the blueprints and think of them as a sub-box. If you open it, you have the chance to draw either 1, 2, ..., or 7 blueprints. So the content of this sub-box is nothing more than a variable $$B$$ with the finite outcomes 1, 2, ..., 7. Gameloft doesn't say anything about the probabilities of each number, so we have to assume that they are all the same. In this case we can compare it with a fair seven-sided die, and the expected number of blueprints we get if we open a very large number of boxes is the simple average:


 * $$\operatorname{E}[B] = \sum_{i=1}^7 i\cdot\frac17 = 1\cdot\frac17 + 2\cdot\frac17 + 3\cdot\frac17 + 4\cdot\frac17 + 5\cdot\frac17 + 6\cdot\frac17 + 7\cdot\frac17= 4$$.

If the seven-sided die wasn't fair, there would be different probabilities assigned to each of the outcomes of $$B$$, and we would get a weighted average. This is the way Gameloft could adjust the number of blueprints you get from a box, even if the description "1-7 blueprints" was still true. To verify this, a very large number of boxes would have to be opened in order to get a valid statistical base for a calculation. I'm talking of 1,000 or more boxes, which is impossible, so we have to live with a certain rest of uncertainty.

How probable is it that I get a certain number of blueprints?
Let's assume you have. With these coins you can buy 3 Expert Bundles for each. As we know that the expected value $$\operatorname{E}[B]$$ is 4, it's tempting to simply multiply the number of boxes with 4, so we should get 12 blueprints. But remember that an expected value needs a very large number of draws to become a good approximation of reality. How reliable is this prediction if we only open 3 boxes?

There are $$7^3$$ permutations, and 4 + 4 + 4 is one of them. It has a probability of $$\tfrac1{7^3}$$ = 0.29 %. But there are other combinations that also grant 12 blueprints: 4 + 5 + 3, for example, or 2 + 3 + 7, each having a probability of $$\tfrac1{7^3}$$.

So if we want to know the probability of getting at least 12 blueprints, we first have to find the number $$c_{12}$$ of combinations whose sum equals 12. As we can also get more than 12 blueprints (and we won't complain), we then have do the same for $$c_{13}$$, $$c_{14}$$, ... up to the maximum number of blueprints we can get, which is the number of boxes multiplied with the maximum number of blueprints per box ($$3 \cdot 7 = 21$$). The sum of the combinations $$c_{12}$$, $$c_{13}$$, ... $$c_{21}$$ is the final number of combinations with at least 12 blueprints from 3 boxes. As each of these combinations has a probability of $$\tfrac1{7^3}$$, the probability $$P(D \ge 12)$$ of getting at least 12 blueprints is


 * $$P(D \ge 12 ) = \frac{c_{12}}{7^3} + \frac{c_{13}}{7^3} + \ldots + \frac{c_{21}}{7^3} $$.

Generally, the probability of getting at least $$d$$ desired items from boxes containing a variable number of guaranteed items is


 * $$P(D \ge d) = \sum_{i=1}^d \frac{c_i}{m^n}$$.

$$m$$: maximum number of items per box $$n$$: number of boxes $$c_i$$: number of combinations with a sum of exactly $$i$$ items $$D$$: event of gotten items $$P(D \ge d)$$: probability of $$D$$ being equal to or greater than $$d$$
 * $$d$$: number of desired items

But we still have to find out the values for $$c_i$$. The general formula to calculate them is


 * $$c_i = \sum_{k=0}^{\left \lfloor \frac{i-n}{m} \right \rfloor} (-1)^k \cdot \binom nk \cdot \binom{i - km - 1}{n - 1}$$.

For those interested in how to derive this formula, there's a good explanation of an analogous example with n-sided dice at StackExchange. "Does HIV cause cardiovascular disease?"

Bla

Bla


 * Each other combination of boxes has the same probability of $$\tfrac{1}{343}$$, but there are several combinations that grant, for example, 20 blueprints (maximum number minus 1): 7-7-6, 7-6-7 and 6-7-7, each with a probability of $$\tfrac{1}{343}$$. So the probability for 20 blueprints is $$\tfrac{3}{343}$$ = 0.87%.

Bla

Bla

with

Summary
Here are all the formulas from the previous parts in a nutshell.

(Part II, Boxes with guaranteed items):
 * Probability of a random item in a box with guaranteed items


 * $$P(D) = \frac{\operatorname{E}[D]}{1 - \operatorname{E}[G]}$$

$$\operatorname{E}[G]$$: expected value of all guaranteed items $$G$$ (sum of all guaranteed percentages in the box info) $$P(D)$$: probability of $$D$$
 * $$\operatorname{E}[D]$$: expected value of the desired random item $$D$$ (percentage in the A8BoxInfoAnniversaryBundle.png box info)

(Part III, Permutation):
 * Number of possibilities (permutations) when buying boxes with random items


 * $$(d+1)^n$$

$$d$$: number of random items of a kind granted per box
 * $$n$$: number of boxes

(Part III, Combination):
 * Number of combinations of a random item in a set of boxes


 * $$\binom nk$$

$$k$$: number of items in the combination
 * $$n$$: number of boxes

(Part III, Combination):
 * Number of possible combinations of a minimum number of a desired item from several boxes


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

$$n$$: number of boxes
 * $$d$$: number of desired items

(Part III, Probability):
 * Probability of one combination in a set of boxes


 * $$(P(D))^d \cdot (1 - P(D))^{n-d}$$

$$d$$: number of desired items $$n$$: number of boxes
 * $$P(D)$$: probability of getting the desired item $$D$$

(Part III, Probability):
 * Probability of getting a minimum number of a desired item from several boxes


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

$$d$$: number of desired items $$n$$: numbeer of boxes
 * $$P(D)$$: probability of getting the desired item $$D$$

Statistical test
Did the calculations withstand the real numbers of items found in opened boxes?

[Adapt probabilities of engines in Expert Bundle! (2 were to be drawn, not 1)]

Further questions
What about the ARSE blueprints?

Complete code
Bla

How many coins do I need to assemble a car with a probability of 90 %?
Bla

Which bundle grants more tokens: Expert or Specialist?
Bla

Appendix
Mercedes-Benz SE:

The amount of boxes needed to get at least 1 (one!) blueprint with a probability of 90 % is


 * $$n \geq \frac{\ln(1 - 0.9)}{\ln(1 - 0.1)} = 21.85$$.