Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This can be done with dynamic programming, I'm not sure if there is a better method as the games are independent.</p> <p>Have a 4-D array, of wins, losses, ties, and games. You can limit wins/losses/ties to the number you want (let these be W, L, T, W+L+T=G) , time complexity will be O(W*L*T*G), which is bounded by O(G⁴).</p> <p>The algorithm is basically:</p> <pre><code>A[][][][] = new double[G+1][W][T][L] // A[g][w][t][l] is the probability of have w wins, t ties, l losses // after g games. This can be computed from A[g-1]. // Let P[g][o] be the probability of outcome o for game g //everything else is initially 0. A[0][0][0][0] = 1 for g=1..G for w=0..W for t=0..T for l=0..L A[g][w][t][l] = A[g-1][w-1][t][l]*P[g][win] // assume out of bounds +A[g-1][w][t-1][l]*P[g][tie] // reference returns 0 +A[g-1][w][t][l-1]*P[g][lose] return A[G][W][T][L] </code></pre> <p><strong>edit)</strong></p> <p>We can do this in O(W*L*T*G/max(W,L,T)), i.e. O(G³). Note that if we have W wins and T ties after G games, then we must have L losses.</p> <pre><code>// we should pick the conditions we loop to be the smallest two. // here we just use wins and ties. A[][][][] = new double[G+1][W][T] A[0][0][0] = 1 for g=1..G for w=0..W for t=0..T A[g][w][t] = A[g-1][w-1][t]*P[g][win] // assume out of bounds +A[g-1][w][t-1]*P[g][tie] // reference returns 0 +A[g-1][w][t]*P[g][lose] return A[G][W][T] </code></pre> <p>Maybe it's possible to do this significantly faster, by computing the probabilities of x wins/ties/losses separately (O(G)), and then adding/subtracting them intelligently, but I haven't found a way to do this.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload