*Author

Offline sleepyoneTopic starter

  • Newbie
  • *
  • Posts: 3
  • Reputation Power: 1
  • sleepyone is a Spark waiting for a buff.
  • New to Elements
Spin Chance Analysis https://elementscommunity.org/forum/index.php?topic=56657.msg1166478#msg1166478
« on: November 16, 2014, 10:36:21 pm »
Note: all this is contingent on the correctness of Xenocidius's simulator.

I'm a bit surprised this hasn't come up, since it's actually not that difficult a problem to solve directly. Why bother? One, it's much faster than running a high number of trials, and two, it has zero variance. Essentially, what the simulator does is select 4 cards from the deck, rejecting pillars in the first eight iterations, then spin using that smaller pool.

Let's make a first approximation by ignoring the chance of getting pillars altogether. To make the math that follows more concise, I'm going to define the following:
P(N, p, k) = (N choose k) * pk * (1-p)N-k = Prob(X=k) for X ~ Binom(N,p)
(look up binomial distribution on wikipedia for more info)

The notation that follows could use some work, but meh.

The probability of a given card appearing k times in the 4 slots is P(4, n/N, k), for n = number of given card in deck, N = total cards in deck.

If said card shows up k times in the pool, then we have a probability (k/4)3 of getting that card on any given spin (since the card needs to come up exactly 3 times). It should be intuitive that the total probability of getting a card from a given spin is the sum from k=1 to 4 (technically 0 to 4, but that first term is 0) of the product of these to terms, i.e.
A := \sumk=04 P(4, n/N, k) * (k/4)3

Repeat for each card in the deck.

Simply applying this formula to the first deck in the AI3 Droprate Tests thread in the Farming Studies / Statistics subforum [nofollow], we get the following results:

CardExpectedSimulator results
Lightning0.04320.042
Parallel Universe0.02360.023
Immortal0.02360.023
Dimensional Shield0.09970.097
Lobotomizer0.02360.024
Phase Dragon0.04320.043
Phase Spider0.06850.067
Mindgate0.06850.067
Silence0.02360.023
As a first approximation, this is very good, although you'll notice that it's a bit optimistic overall, since I've assumed that pillars won't appear in the pool.

So what happens if we add back p pillars? This part gets a bit more complicated, although we can still explicitly solve it without even resorting to more complicated mathematical constructs like Markov chains.

Let's start by considering 4 additional events E5 through E8, corresponding to 5-8 pillars out of first 8 cards chosen.

Event Ei simply appears with probability P(8, p/(N+p), i).

Given event Ei, the probability that a given non-pillar card appears k times looks like:
\sumj=0k P(8-i, n/N, j) * P(i-4, n/(N+p), k-j)
(win j copies of the card in the first 8, then k-j copies in the remaining trials)

Similarly, the probability that a given pillar card appears k times is:
P(i-4, n/(N+p), k)

Let's assemble all these parts now. The probability of winning a card that appears n times in a deck with N non-pillars and p pillars is
(1 - \sumi=58 P(8, p/(N+p))) * A + \sumi=58 P(8, p/(N+p), i) \sumk=04  (k/4)3 \sumj=0kP(8-i, n/N, j) * P(i-4, n/(N+P), k-j)
if the card is not a pillar, and
\sumi=58 \sumk=04 P(8, p/(N+p), i) * P(i-4, n/(N+P), k)
if it is.

This final formula (as evaluated by the below javascript code) yields the following results on that same ai3 deck:

CardExpectedSimulator results
Aether Pillar0.00380.004
Lightning0.04230.042
Parallel Universe0.02320.023
Immortal0.02320.023
Dimensional Shield0.09730.097
Lobotomizer0.02320.024
Phase Dragon0.04230.043
Phase Spider0.06690.067
Mindgate0.06690.067
Silence0.02230.023
Hope someone finds this at least entertaining.

Code: [Select]
function choose(n,k) {
    var ret = 1;
    for (var i = 0; i < k; i++) {
        ret = ret * (n - i) / (k - i);
    }
    return ret;
}

function prob(N, p, k) {
    // binomial pdf with parameters N, p
    return choose(N,k) * Math.pow(p, k) * Math.pow(1 - p, N-k);
}

function pillarless_yields(n, N) {
    var sum = 0;
    for (var i = 0; i <= 4; i++) {
        sum += Math.pow(i/4, 3) * prob(4, n/N, i);
    }
    return sum;
}

function yields(n, N, P, pillar) {
    // pillar is true if this item is a pillar.
    var psum = 0;
    var sum = 0;
    for (var i = 5; i <= 8; i++) {
        var p = prob(8, P/(N+P), i);
        psum += p;
        for (var k = 0; k < 4; k++) {
            if (!pillar) {
                for (var j = 0; j <= k; j++) {
                    sum += p * Math.pow(k/4, 3) * prob(8-i, n/N, j) * prob(i-4, n/(N+P), k-j);
                }
            } else {
                sum += p * Math.pow(k/4, 3) * prob(i-4, n/(N+P), k);
            }
        }
    }
    if (!pillar) {
        sum += pillarless_yields(n, N) * (1-psum);
    }
    return sum;
}


// These are the distribution of cards in the ai3 aether deck.
var arr = [3,2,2,5,2,3,4,4,2];

console.log(arr.map(function (x) {return 3*yields(x, 27, 15, false);}).join('\n'));;
console.log(3*yields(15, 27, 15, true));
« Last Edit: November 18, 2014, 01:47:19 am by sleepyone »

Offline 10 men

  • Sr. Member
  • ****
  • Posts: 987
  • Country: de
  • Reputation Power: 0
  • 10 men hides under a Cloak.
  • Honesty is the privilege of the infallible
  • Awards: 6th Trials - Master of TimeWinner of Draft #3 - PvP EventWeekly Tournament WinnerWeekly Tournament Winner5th Trials - Master of Time4th Trials - Master of TimeWeekly Tournament WinnerWeekly Tournament WinnerShard Revolution WinnerSlice of Elements 2nd Birthday CakeWar #2 Winner - Team Entropy
Re: Spin Chance Analysis https://elementscommunity.org/forum/index.php?topic=56657.msg1166483#msg1166483
« Reply #1 on: November 16, 2014, 11:31:39 pm »
You are absolutely right that Xeno's Simulator is kinda inelegant for determining all the droprates. Back when we investigated drop rates in the wake of the FG farming study, we used the exact numbers as well.
« Last Edit: November 16, 2014, 11:39:58 pm by 10 men »
"My big fear is that one day I may become so vain that I will quote myself in my own signature."  ---  10 men

Offline sleepyoneTopic starter

  • Newbie
  • *
  • Posts: 3
  • Reputation Power: 1
  • sleepyone is a Spark waiting for a buff.
  • New to Elements
Re: Spin Chance Analysis https://elementscommunity.org/forum/index.php?topic=56657.msg1166491#msg1166491
« Reply #2 on: November 17, 2014, 12:33:15 am »
Interesting, I guess I completely missed that thread. I just played a game in the trainer and confirmed in the actual game that more than four unique cards can come up in the same set of spins. If I had to guess, this means that either the spins are independent but the model is correct (best-case scenario), or the model is simply incorrect (e.g. pool is larger than four cards).

edit: if the model still needs confirming, obviously the bonus electrum (first two slots are the same) is more frequent than bonus card, which yields a lower relative variance (so fewer trials needed to be more certain). The problem is actually gathering the data in the first case, I suppose.
« Last Edit: November 17, 2014, 12:45:06 am by sleepyone »

Offline 10 men

  • Sr. Member
  • ****
  • Posts: 987
  • Country: de
  • Reputation Power: 0
  • 10 men hides under a Cloak.
  • Honesty is the privilege of the infallible
  • Awards: 6th Trials - Master of TimeWinner of Draft #3 - PvP EventWeekly Tournament WinnerWeekly Tournament Winner5th Trials - Master of Time4th Trials - Master of TimeWeekly Tournament WinnerWeekly Tournament WinnerShard Revolution WinnerSlice of Elements 2nd Birthday CakeWar #2 Winner - Team Entropy
Re: Spin Chance Analysis https://elementscommunity.org/forum/index.php?topic=56657.msg1166492#msg1166492
« Reply #3 on: November 17, 2014, 12:44:03 am »
If I had to guess, this means that either the spins are independent but the model is correct

Yes, that is the case. For each spin the algorithm is performed seperately. Fwiw the algorithm was pulled directly from the game code by Dark Weaver. Of course it's possible that the algorithm changed in the last 3 years, but I'm pretty sure it didn't - there weren't many updates since then and I also didn't notice any differences in spin behavior.
"My big fear is that one day I may become so vain that I will quote myself in my own signature."  ---  10 men

Offline CuCN

  • Hero Member
  • *****
  • Posts: 1756
  • Reputation Power: 25
  • CuCN is a proud Wyrm taking wing for the first time.CuCN is a proud Wyrm taking wing for the first time.CuCN is a proud Wyrm taking wing for the first time.CuCN is a proud Wyrm taking wing for the first time.CuCN is a proud Wyrm taking wing for the first time.
  • Toxic
  • Awards: Slice of Elements 5th Birthday CakeSlice of Elements 4th Birthday Cake
Re: Spin Chance Analysis https://elementscommunity.org/forum/index.php?topic=56657.msg1166497#msg1166497
« Reply #4 on: November 17, 2014, 01:42:39 am »
Overall this looks correct.

Your javascript code does this correctly, but there's a mistake in the formula posted here. The fourth sum, across j, is missing.
Let's assemble all these parts now. The probability of winning a card that appears n times in a deck with N non-pillars and p pillars is
(1 - \sumi=58 P(8, p/(N+p))) * A + \sumi=58 P(8, p/(N+p), i) \sumk=04 (k/4)3 * P(8-i, n/N, k) * P(i-4, n/(N+P), k)
if the card is not a pillar

Offline sleepyoneTopic starter

  • Newbie
  • *
  • Posts: 3
  • Reputation Power: 1
  • sleepyone is a Spark waiting for a buff.
  • New to Elements
Re: Spin Chance Analysis https://elementscommunity.org/forum/index.php?topic=56657.msg1166634#msg1166634
« Reply #5 on: November 18, 2014, 01:47:38 am »
Good catch, I guess I just got a bit overzealous with the copy-pasting. Fixed in the original post.

Offline CuCN

  • Hero Member
  • *****
  • Posts: 1756
  • Reputation Power: 25
  • CuCN is a proud Wyrm taking wing for the first time.CuCN is a proud Wyrm taking wing for the first time.CuCN is a proud Wyrm taking wing for the first time.CuCN is a proud Wyrm taking wing for the first time.CuCN is a proud Wyrm taking wing for the first time.
  • Toxic
  • Awards: Slice of Elements 5th Birthday CakeSlice of Elements 4th Birthday Cake
Re: Spin Chance Analysis https://elementscommunity.org/forum/index.php?topic=56657.msg1167262#msg1167262
« Reply #6 on: November 21, 2014, 02:15:35 am »
I've found a minor mistake in your program that affects the numbers by about 0.0001. In the "yields" function, the loop for k should have "k <= 4", not "k < 4".

The summations can be reduced to polynomials in two variables.
Let x=n/(N+p) and let y=p/(N+p). Then the probability of winning a card is
(1/16)(x(1+y+y2+y3+y4+y5-13y6+15y7-5y8)+x2(9+18y+27y2+36y3+45y4+54y5-189y6+72y7+15y8)+x3(6+18y+36y2+60y3+90y4+126y5-84y6-36y7-6y8))
if the card is not a pillar, and otherwise:
(1/16)(x(14y5-28y6+20y7-5y8)+x2(42y6-48y7+15y8)+x3(12y7-6y8))

The polynomials in y only need to be calculated once for each deck, so it comes down to a cubic equation in x.

For example, when y=15/42 (as for the ai3 deck with 15 pillars in 42 cards), the probability of a card that isn't a pillar is
(1/23612624896)(2265548601x+31321258539x2+32094593346x3)
and for a pillar
(1/23612624896)(54221875x+81984375x2+10781250x3)

giving the results:

CardCopiesCalculated (x3)
Aether Pillar150.00385132
Lightning30.042349
Parallel Universe20.0231705
Immortal20.0231705
Dimensional Shield50.0975435
Lobotomizer20.0231705
Phase Dragon30.042349
Phase Spider40.0670299
Mindgate40.0670299
Silence20.0231705
« Last Edit: November 21, 2014, 04:15:00 am by CuCN »

 

anything
blarg: