How to calculate the combination of matrix of probabilities (win rate ranking in game)

Viewed 95

Let imagine we have a game with 4 players. And after playing game, we will get ranking of 4 players based on their score, rank 1 is the best, rank 4 is the worst. I have created a model for predicting player ranking. In detail, I have created 2 models for predict who will be in rank1 and rank2 of the game:

  • model A predict probabilities for who win in rank 1.
  • model B predict probabilities for who win in rank 2.

And all of probability outputs will be in this matrix:

PlayerID Rank1(prob) Rank2(prob)
PlayerA 0.7 0.8
PlayerB 0.2 0.05
PlayerC 0.1 0.1
PlayerD 0.1 0.05

Based on above table, how can I calculate probability for this event: "Player A and Player B will be in first 2 ranks" ? Please help

2 Answers

if the chance of player B winning second place does change after we know that player A won first place (since player A can't both first and second place) the answer should be calculated as follows:

the probability of player A winning first place and player B winning second place is (A winning first) * (B wining second given A won ) = 0.7*0.25=0.175

since (B wining second given A won ) = 0.05/(0.1+0.05+0.05) = 0.25

the probability of player A winning second place and player B winning second place is (B winning first) * (A winning second given B won ) =0.8*0.84 = 0.168

since (A wining second given B won ) = 0.8/0.95 = 0.84

and by the law of total probability, since the two events above cant occur together:

so the probability that any of the cases will occur is

 0.175+0.168= 0.343

to put it into code, assuming that the name of your matrix is "mat"

ans = mat[0][0]*(mat[1][1]/(1-mat[0][1)) + mat[1][0]*(mat[1][0]/(1-mat[1][1]))
print(ans)

output:

0.343

and if the probability of player B getting the second place does not change even if we know that player A won first place (meaning they are independent) then:

the probability of player A is in the first place and player B in second place = 0.7*0.05 = 0.0345

the probability of player A is in the second place and player B in first place = 0.8*0.2=0.16

and by the law of total probability, since the two events above cant occur together:

so the probability that any of the cases will occur is 0.16+0.0345 = 0.1945

to put it into code, assuming that the name of your matrix is "mat"

ans = mat[0][0]*mat[1][1] + mat[0][1]*mat[1][0]
print(ans)

output:

0.1945

hope I could help :) if you have any questions feel free to ask in the comments

The Premise

First of all, you have a bug in your premise. You predict a probability of 0.7 for PlayerA to be at first place and you have a prediction for the same PlayerA to be ranked 2nd at the same game with a probability of 0.8. A value of 1 means full certainty, a value of 0 means full certainty of the negation. Now, your

0.7 + 0.8 = 1.5

which violates the basic framework of boolean algebra, as summing the probabilities of distinct outcomes for the same event you get a higher value than the maximum supported value of 1.

Also, there should be some probability of PlayerA being ranked lower than 2., so we should have

P(first) + P(second) + P(lower) = 1

for any player. If this is false (and in your case it is false), then the premise is incorrect.

Another problem with the premise can be seen from the fact that summing Rank1(prob) we get 1.1, even though, summing Rank2(prob) we get the expected value of 1.

But let's focus on Rank1(prob) at this point.

We know as an absolutely certain fact (probability of 1) that one of the four players will be ranked 1, which means that their probability should have a sum that is exactly equal to 1. Since it is 1.1 (0.7 + 0.2 + 0.1 + 0.1) in your case, we see another problem with your premise. So, first things first: you need to fix your premise to make sure that they are corresponding to reality and they do not violate the basic framework of boolean logic (violating this framework is an absolutely sure sign of not being in line with reality)

Logics and Probability

In probability calculation, applying logics is not difficult. For example, if you are interested to know whether p(X) AND p(y) is true, then you can compute it like this:

p(X AND Y) = p(X) * p(Y)

Explanation: The probability itself is a conjunction already with the surety (value of 1), as p(X) = 1 * p(X). 0 <= p(X) <= 1 is the full problem-space when you calculate the result of logical AND with p(Y), hence you compute a further conjunction, resulting in p(X) * p(Y)

In the case of logical OR

Computing the disjunction is as

p(X OR Y) = p(X) + p(Y) - p(X AND Y) = p(X) + p(Y) - p(X) * p(Y)

Explanation: Intuitively, the result of the logical OR should be the sum of the cases, but there is a caveat: p(X AND Y) is already included as a possibility both into p(X) and p(Y), so it appears twice (in a hidden manner) when you compute p(X) + p(Y), so, as a result, you need to subtract it to make sure that it's computed into the result exactly once.

Computing your formula

We are interested to know whether PlayerA will be first and PlayerB will be second or PlayerB will be first and PlayerA will be second.

Since your premises have some bugs, I will not use your values. Instead of that, I will denote Rank1(A) as the probability that PlayerA will be ranked first and so on.

So:

p(Rank1(A) AND Rank2(B)) = Rank1(A) * Rank2(B) (1)

Similarly:

p(Rank1(B) AND Rank2(A)) = Rank1(B) * Rank2(A) (2)

So:

p((Rank1(A) AND Rank2(B)) OR (Rank1(B) AND Rank2(A))) = p(Rank1(A) AND Rank2(B)) + p(Rank1(B) AND Rank2(A)) - p((Rank1(A) AND Rank2(B)) AND (Rank1(B) AND Rank2(A)))

We know that p((Rank1(A) AND Rank2(B)) AND (Rank1(B) AND Rank2(A))) is exactly 0, because it is a self-contradiction, because it assumes PlayerA to be ranked first and second at the same time and it similarly assumes PlayerB to be ranked first and second at the same time. So:

p(Rank1(A) AND Rank2(B)) + p(Rank1(B) AND Rank2(A)) - p((Rank1(A) AND Rank2(B)) AND (Rank1(B) AND Rank2(A))) = p(Rank1(A) AND Rank2(B)) + p(Rank1(B) AND Rank2(A)) - 0 = p(Rank1(A) AND Rank2(B)) + p(Rank1(B) AND Rank2(A))

Let's apply formula (1) and (2) at the same time:

p(Rank1(A) AND Rank2(B)) + p(Rank1(B) AND Rank2(A)) = Rank1(A) * Rank2(B) + Rank1(B) * Rank2(A)

Related