Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

With the trueskill algorithm, given two players' ratings, how can I calculate the win/loss probability?

I see this question come up a lot in discussions of trueskill, but I've yet to come across a conclusive answer.

I'm using the Python implementation here:

https://github.com/sublee/trueskill

I've put together a simple simulation using that library here:

https://gist.github.com/klenwell/3a15eca6b83ce575d0ca

The question is submitted as the first issue for the Python library. In the Jeff Moser blog post which most trueskill discussions lead back to, the question comes up several times in the comments.

Can someone provide a function compatible with the Python library implementation that accurately returns a player's predicted win probability against another player based on the two players ratings?

like image 449
klenwell Avatar asked Sep 05 '25 16:09

klenwell


1 Answers

Here's a function based on this comment on the Moser blog:

from math import sqrt
from trueskill import BETA
from trueskill.backends import cdf

def win_probability(player_rating, opponent_rating):
    delta_mu = player_rating.mu - opponent_rating.mu
    denom = sqrt(2 * (BETA * BETA) + pow(player_rating.sigma, 2) + pow(opponent_rating.sigma, 2))
    return cdf(delta_mu / denom)

Tested with my gist, this seems to perform better than original win_probability function found here.

This function only handles the head-to-head case, but the comment includes a more general approach for calculating win probabilities for a multi-player match.

like image 143
klenwell Avatar answered Sep 07 '25 10:09

klenwell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!