Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

float division by zero #3

Closed
youknowone opened this issue Sep 3, 2012 · 7 comments
Closed

float division by zero #3

youknowone opened this issue Sep 3, 2012 · 7 comments

Comments

@youknowone
Copy link

@youknowone youknowone commented Sep 3, 2012

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
@sublee
Copy link
Owner

@sublee sublee commented Sep 3, 2012

Please include the input ratings that drives the error.

@konikos
Copy link

@konikos konikos commented Oct 5, 2012

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
@sublee
Copy link
Owner

@sublee sublee commented Oct 5, 2012

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

@sublee
Copy link
Owner

@sublee sublee commented Oct 5, 2012

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
    
@konikos
Copy link

@konikos konikos commented Oct 5, 2012

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

@sublee
Copy link
Owner

@sublee sublee commented Oct 5, 2012

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

sublee pushed a commit that referenced this issue Oct 5, 2012
Heungsub Lee
fix issue #3 (ZeroDivisionError)
@sublee
Copy link
Owner

@sublee sublee commented Oct 5, 2012

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
@sublee sublee closed this Oct 5, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.