nandbit

[index] [fun] [about]
Determining lootbox chances

Introduction

Imagine you have a lootbox with N possible item tiers. For example:

  • Common
  • Uncommon
  • Rare
  • Legendary

Now let's say we would like to have the probability of rarer items to be exponentially less likely to be drawn from a lootbox than the tier above. What are the assigned probabilities to each tier?


Math

My initial solution was formulated as:

i = 1 n e x i = 1 e x + e 2 x + . . . + e n x = 1

Let's try a concrete example with 4 tiers

i = 1 4 e x i = 1 x 0.65626

So the tier drop chances would be

Tier Expression Probability
Common e 1 ( 0.65626 ) 0.518788...
Uncommon e 2 ( 0.65626 ) 0.269141...
Rare e 3 ( 0.65626 ) 0.139627...
Legendary e 4 ( 0.65626 ) 0.072437...

Generalization (it's more math)

My formulation is okay but it's not generalizeable. What if we want to use another base besides e? What if we would like to have a specific lowest/highest probability? A friend of mine helped me come up with a generalized formula to answer these questions

1 = k 0 p + k 1 p + . . . + k n p

Here, k is essentially the scaling factor for the chosen set probability. If we choose the common tier to have the probability of 0.5, and n = 4 , we get

1 = k 0 ( 0.5 ) + k 1 ( 0.5 ) + k 2 ( 0.5 ) + k 3 ( 0.5 )

Solving for k yields

k 0.54369

Plugging it back into the equation gives us the following probabilities

Tier Expression Probability
Common 0.54369 0 ( 0.5 ) 0.5
Uncommon 0.54369 1 ( 0.5 ) 0.271845
Rare 0.54369 2 ( 0.5 ) 0.147799
Legendary 0.54369 3 ( 0.5 ) 0.080357

We can actually choose any one tier to have a specific probability to calculate the rest off of. Let's say we want the rarest tier to have the probability of 1%. What we need to do is to "isolate" it in our equation

1 = k 0 p + k 1 p + k 2 p + k 3 p

To do that we divide the probabilities of the other elements by the prefix of the probability we want to keep constant

1 = k 0 k 3 ( 0.01 ) + k 1 k 3 ( 0.01 ) + k 2 k 3 ( 0.01 ) + 0.01 Solving for k yields k 0.23536...

And one more time plugging the values...

Tier Expression Probability
Common 0.23536 0 0.23536 3 ( 0.01 ) 0.76701
Uncommon 0.23536 1 0.23536 3 ( 0.01 ) 0.18052
Rare 0.23536 2 0.23536 3 ( 0.01 ) 0.04249
Legendary 0.01 0.01

Notes

  1. My original formulation is a special case of the generalized formula where k = e x and p = e x