Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

float division by zero #3

Closed
youknowone opened this Issue · 7 comments

3 participants

Jeong YunWon Heungsub Lee Nikos Kokolakis
Jeong YunWon
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "trueskill/__init__.py", line 416, in transform_ratings
    return g().transform_ratings(rating_groups, ranks, min_delta)
  File "trueskill/__init__.py", line 341, in transform_ratings
    self.run_schedule(*layers, min_delta=min_delta)
  File "trueskill/__init__.py", line 288, in run_schedule
    teamdiff_layer[0].up(0)
  File "trueskill/factorgraph.py", line 140, in up
    return self.update(self.terms[index], vals, msgs, coeffs)
  File "trueskill/factorgraph.py", line 145, in update
    pi = 1. / sum(coeffs[x] ** 2 / divs[x].pi for x in xrange(size))
  File "trueskill/factorgraph.py", line 145, in <genexpr>
    pi = 1. / sum(coeffs[x] ** 2 / divs[x].pi for x in xrange(size))
ZeroDivisionError: float division by zero
Heungsub Lee
Owner

Please include the input ratings that drives the error.

Nikos Kokolakis

Same for me for the following datasets:

team1 = (Rating(mu=42.234, sigma=3.728), Rating(mu=43.290, sigma=3.842))
team2 = (Rating(mu=16.667, sigma=0.500), Rating(mu=16.667, sigma=0.500), Rating(mu=16.667, sigma=0.500), Rating(mu=16.667, sigma=0.500), Rating(mu=16.667, sigma=0.500), Rating(mu=16.667, sigma=0.500), Rating(mu=16.667, sigma=0.500), Rating(mu=16.667, sigma=0.500), Rating(mu=16.667, sigma=0.500), Rating(mu=16.667, sigma=0.500), Rating(mu=16.667, sigma=0.500), Rating(mu=16.667, sigma=0.500), Rating(mu=16.667, sigma=0.500), Rating(mu=16.667, sigma=0.500), Rating(mu=16.667, sigma=0.500))
transform_ratings([team1, team2], ranks=[6, 5])

and

team1 = (Rating(mu=25.000, sigma=0.500), Rating(mu=25.000, sigma=0.500), Rating(mu=25.000, sigma=0.500), Rating(mu=25.000, sigma=0.500), Rating(mu=33.333, sigma=0.500), Rating(mu=33.333, sigma=0.500), Rating(mu=33.333, sigma=0.500), Rating(mu=33.333, sigma=0.500), Rating(mu=41.667, sigma=0.500), Rating(mu=41.667, sigma=0.500), Rating(mu=41.667, sigma=0.500), Rating(mu=41.667, sigma=0.500))
team2 = (Rating(mu=42.234, sigma=3.728), Rating(mu=43.291, sigma=3.842))
transform_ratings([team1, team2], ranks=[0,28])

Using python 2.7 and trueskill 0.1.3 from pypi results to

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/tmp/venv/local/lib/python2.7/site-packages/trueskill/__init__.py", line 414, in transform_ratings
    return g().transform_ratings(rating_groups, ranks, min_delta)
  File "/tmp/venv/local/lib/python2.7/site-packages/trueskill/__init__.py", line 339, in transform_ratings
    self.run_schedule(*layers, min_delta=min_delta)
  File "/tmp/venv/local/lib/python2.7/site-packages/trueskill/__init__.py", line 286, in run_schedule
    teamdiff_layer[0].up(0)
  File "/tmp/venv/local/lib/python2.7/site-packages/trueskill/factorgraph.py", line 140, in up
    return self.update(self.terms[index], vals, msgs, coeffs)
  File "/tmp/venv/local/lib/python2.7/site-packages/trueskill/factorgraph.py", line 145, in update
    pi = 1. / sum(coeffs[x] ** 2 / divs[x].pi for x in xrange(size))
  File "/tmp/venv/local/lib/python2.7/site-packages/trueskill/factorgraph.py", line 145, in <genexpr>
    pi = 1. / sum(coeffs[x] ** 2 / divs[x].pi for x in xrange(size))
ZeroDivisionError: float division by zero
Heungsub Lee
Owner

@konikos I've been waiting for any failure cases. I'll review this problem soon. Thanks!

Heungsub Lee
Owner

I checked another implementations. But,

  1. TrueSkill Calcurator by Microsoft doesn't support more than 8 players.
  2. @moserware's C# implementation also cannot calculate 1st case:

    p1 -> μ=NaN, σ=3.7289
    p2 -> μ=NaN, σ=3.8429
    p3~p17 -> μ=NaN, σ=0.5069
    
Nikos Kokolakis

Ok, nice to know but is there any simple workaround?

Heungsub Lee
Owner

@konikos This issue isn't closed yet. I'm still trying to get a nice solution.

Heungsub Lee sublee referenced this issue from a commit
Heungsub Lee version 0.1.4
fix issue #3 (ZeroDivisionError)
c6bb21d
Heungsub Lee
Owner

This issus is fixed at version 0.1.4. I also added the cases into the test suite. Here's new result of first case:

p1 -> μ=42.234, σ=3.729
p2 -> μ=43.290, σ=3.843
p3~p17 -> μ=16.667, σ=0.507
Heungsub Lee sublee closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.