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 that all probabilities are the same (that is, $$p_1 = p_2 = \ldots = p_k$$), then the weighted average turns into the simple average.

Example: If $$X$$ represents the outcome of a roll of a fair six-sided, the possible values for $$X$$ are 1, 2, 3, 4, 5, and 6, all equally likely (each having the probability of ). 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.$$

If all outcomes of $$X$$ have the same probability $$p$$,


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

Special case: Blueprints in the Expert Bundle
The Expert Bundle has a specialty: It contains guaranteed blueprints, but you don't know the exact number you'll get—it can vary from 1 to 7. How many can you expect?

This is easier to understand if you regard it as two separate boxes: The Expert Bundle is a box that contains a surprise box $$S$$. The surprise box $$S$$ contains a number of blueprints $$B$$ between 1 and 7.

When you open the Expert Bundle, you get the surprise box $$S$$ with the probability $$P(S) = 100 %$$ and the expectation $$\operatorname{E}[S] = 25 %$$ (because it's 1 of 4 items).

Now the surprise box is opened. You can imagine this as rolling a seven-sided die. If the die is fair, each number of pips has the same probability of showing on the top face after the toss.


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

In this case, the expected value is a simple average.

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)^b$$

$$d$$: number of random items of a kind granted per box
 * $$b$$: 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 blueprints do I get for n coins?
Let's assume that you have. With those coins you can buy either
 * 3 Expert Bundles ( each) or
 * 7 Specialist Bundles ( each) or
 * 14 Novice Bundles ( each).

The Expert bundle grants at least 1 Audi R8 e-tron SE blueprint per box; the maximum number you can get is 7. Assumed that there are no underlying probabilities for certain amounts of blueprints, you can imagine this as an urn containing 7 boxes: one box with 1 blueprint, one box with 2, one with 3 and so on. If you draw one box from the urn, each box and thus each amount of blueprints has the same probability: $$\tfrac{1}{7}$$.

As you can buy 3 Expert Bundles for your coins, you can draw 3 times from the urn (with putting back the drawn item).
 * The probability of getting the maximum number of blueprints from 3 draws (i. e. 3 times box number 7) is $$\tfrac{1}{7} \cdot \tfrac{1}{7} \cdot \tfrac{1}{7} = \tfrac{1}{7^3} = \tfrac{1}{343}$$ = 0.29%.
 * 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%.
 * This leads to the question in how many ways you can combine three summands from 1 to 7 so that the result is the desired number of blueprints. You can imagine that as throwing a seven-sided dice three times. Technically, this is a special case of a composition problem which is examined in combinatorics (see Wikipedia article for further explanations).

The probability of getting the maximum number of items from d draws out of n items is $$\frac{1}{n^d}$$.

As the number of draws equals the number of boxes you can buy, the number of boxes is defined by $$\lfloor\frac{amount of coins}{box price}\rfloor$$ Bla

\begin{align} m &= \sum_{k=0}^{\lfloor \frac{s-n}{7} \rfloor} (-1)^k \cdot \binom nk \cdot \binom{s - 1 - 7k}{n - 1}\\ &= \sum_{k=0}^{\lfloor\frac{s-n}{7}\rfloor} (-1)^k \cdot \frac{n!}{k! \cdot (n-k)!} \cdot \binom{s - 1 - 7k}{n - 1} \end{align} $$

Bla

with m: probability of a sum n: amount of boxes s: sum of blueprints

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$$.