Skip to content

Conversation

Navodhya-Fernando
Copy link

🎯 Feature: Implement the Elo Expected Score Formula

📋 Description

This PR introduces the calculate_elo_expected_score function to the math section. This function is a core component of the widely used Elo Rating System, which determines the expected outcome of a match between two players based on their current ratings.

⚽ Why This Matters (Sports Industry Relevance)

This algorithm is directly applicable to statistical analysis in many competitive fields, including:

  • Sports Analytics: Ranking teams/players in chess, football, basketball, and esports.
  • Predictive Modeling: Calculating the probability of a win, which informs betting odds and team strategy.

🔧 What's Added

  • New File: maths/elo_expected_score.py
  • New Function: calculate_elo_expected_score(rating_a, rating_b)
  • Includes: Necessary import math and a basic if __name__ == '__main__' usage example.

✅ Checklist

  • Code adheres to repository style guides.
  • Includes a comprehensive docstring explaining the formula and parameters.
  • Includes a self-testing block (if __name__ == '__main__':).
  • Added to the correct category (maths).

🎃 Hacktoberfest 2025
This is submitted as a high-quality contribution, adding a practical and mathematically significant algorithm to the collection.

@algorithms-keeper algorithms-keeper bot added the require type hints https://docs.python.org/3/library/typing.html label Oct 13, 2025
Copy link

@algorithms-keeper algorithms-keeper bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

exponent = (rating_b - rating_a) / 400
return 1.0 / (1.0 + math.pow(10, exponent))

def test_calculate_elo_expected_score():

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide return type hint for the function: test_calculate_elo_expected_score. If the function does not return a value, please provide the type hint as: def function() -> None:

@algorithms-keeper algorithms-keeper bot added the awaiting reviews This PR is ready to be reviewed label Oct 13, 2025
@algorithms-keeper algorithms-keeper bot added the tests are failing Do not merge until tests pass label Oct 13, 2025
@cclauss
Copy link
Member

cclauss commented Oct 14, 2025

Closing require_type_hints PRs to prepare for Hacktoberfest

@cclauss cclauss closed this Oct 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting reviews This PR is ready to be reviewed require type hints https://docs.python.org/3/library/typing.html tests are failing Do not merge until tests pass

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants