In case there is interest, I thought I'd talk about some probabilities in Spiral Knights. Specifically, if every time you try something you have a 1 in N chance of succeeding, then how many times will you have to try, before you succeed? For example:
- If about 3% of all Lockboxes contain Shadow Keys, then how many Lockboxes do you need to open, to find one?
- If you want a CTR UV on a weapon, and this happens about 1 in 8 times you buy a single UV, then how many times do you need to buy, to get one?
First, here are some general answers. We assume that each try has a 1 in N chance of succeeding, independent of the other tries.
- The expected number of tries, to succeed once, is N. (Edit: Think of this as the average number of tries required per successful try.)
- For any integer A >= 1, the probability that your first success will happen in the first A tries is 1 - (1 - 1 / N)^A.
- For any integer B such that 0 <= B < N, the probability that your first success will happen between your (N - B)th try and your (N + B)th try is (1 - 1 / N)^(N - B - 1) - (1 - 1 / N)^(N + B).
In the case of Shadow Keys, our best current data suggest that they show up about 1 in 33 times. So N = 33. You expect to try about 33 times, before you find one. You have about a 50% chance of your first Shadow Key showing up in your first 23 tries. There is a 64% chance of your first Shadow Key showing up in your first 33 tries. There's a 50% chance of your first Shadow Key showing up between your 13th and 53rd tries.
In the case of rolling for CTR UVs, suppose that each possible UV on a weapon (CTR, ASI, slime, gremlin, beast, fiend, undead, construct) has an equal chance of happening. Then N = 8. You expect to try about 8 times, before you get a CTR UV. There's a 50% chance of a CTR UV showing up in your first 5 tries. There's a 50% chance of your first CTR UV showing up between your 3rd and 13th tries. (The same logic applies to ASI UVs, fiend UVs, etc. But I don't really know whether all UV types have an equal chance of happening.)
In case anyone wants to check my work, or ask different questions about the same idea, here is a brief sketch of the logic. It's all based on the geometric distribution.
- The probability that your first success happens on try K is equal to (1 - 1 / N)^(K - 1) (1 / N), because you must fail K - 1 times and then succeed. Call this number P(K).
- From probability theory, the expectation is the sum of K P(K), where K ranges from 1 to infinity. This sum simplifies down to N.
- The probability that your first success happens in the first A tries is the sum of P(K), where K ranges from 1 to A. This simplifies down to the answer I gave above.
- The probability that your first success happens between your (N - B)th try and your (N + B)th try is the probability that it happens in your first N + B tries, minus the probability that it happens in your first N - B - 1 tries. You can compute each of those already; just subtract.
My... brain... hurts @____@