
    
        
        
        
            
{"version":"https:\/\/jsonfeed.org\/version\/1","title":"mathspp.com feed","home_page_url":"https:\/\/mathspp.com\/blog\/tags\/streamlit","feed_url":"https:\/\/mathspp.com\/blog\/tags\/streamlit.json","description":"Stay up-to-date with the articles on mathematics and programming that get published to mathspp.com.","author":{"name":"Rodrigo Gir\u00e3o Serr\u00e3o"},"items":[{"title":"Elo rating system simulation","date_published":"2022-01-25T00:00:00+01:00","id":"https:\/\/mathspp.com\/blog\/elo-rating-system-simulation","url":"https:\/\/mathspp.com\/blog\/elo-rating-system-simulation","content_html":"<p>Join me as I create a simulation that tries to test an Elo-based rating system for quizzes.<\/p>\n\n<figure class=\"image-caption\"><img title=\"Screenshot of the simulation web app.\" alt=\"Screenshot of a Python Streamlit web app.\" src=\"\/images\/a\/1\/3\/6\/2\/a1362e99125e7c0764cc35a8e9d02d4a224f3260-thumbnail.webp\"><figcaption class=\"\">Screenshot of the simulation web app.<\/figcaption><\/figure><h2 id=\"introduction\">Introduction<a href=\"#introduction\" class=\"toc-anchor after\" data-anchor-icon=\"#\" aria-label=\"Anchor\"><\/a><\/h2>\n<p>In this article, I will tell you about a simulation that I built.\nThis simulation is built around a rating system that is based off of the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Elo_rating_system\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">Elo rating system<\/a>,\nand I will use <a href=\"\/blog\/til\/026\">Streamlit<\/a> to build the app that will control the simulation.\nThis will also make it easier to share the simulation with others.<\/p>\n<p>In short, I'll be walking you through the process of writing <a href=\"https:\/\/github.com\/mathspp\/elo-simulation\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">this code<\/a> and,\nin the end, the code I linked to in that GitHub repository is going to be used\nto host the Streamlit web app that you can play with live, <a href=\"https:\/\/share.streamlit.io\/mathspp\/elo-simulation\/main\/simulation.py\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">here<\/a>.<\/p>\n<p>The screenshot above also refers to the same Streamlit web app.<\/p>\n<h2 id=\"elo-based-rating-system-for-quizzes\">Elo-based rating system for quizzes<a href=\"#elo-based-rating-system-for-quizzes\" class=\"toc-anchor after\" data-anchor-icon=\"#\" aria-label=\"Anchor\"><\/a><\/h2>\n<p>What I'm trying to do is design a decent rating system for a quiz app.\nThe idea is that the quiz questions will have a rating,\nand so will the &ldquo;players&rdquo;: the people answering the quiz.<\/p>\n<p>Every time a person answers a question, their rating gets adjusted depending on whether they answered the question correctly.\nSimilarly, the question's rating gets updated.\nIf the player answers correctly, the player's rating goes up and the question's goes down.\nIf the player answers incorrectly, the ratings change the other way around.<\/p>\n<p>So, how can we build such a system?<\/p>\n<p>The <a href=\"https:\/\/en.wikipedia.org\/wiki\/Elo_rating_system\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">Elo rating system<\/a> is a system that attributes a numeric rating to players,\nin order to determine the relative skill of the players.\nThe Elo rating is probably best known for being the rating used in chess.<\/p>\n<p>I have seen the website chess.com use an Elo-like system for their chess problems:\nyou play the problem and, if you get it right, your problem-solving rating increases;\nat the same time, the rating of the problem decreases.\nIf you get it wrong, vice-versa.\nI want to try and mimic this functionality.<\/p>\n<p>The purpose of building a simple simulation is to try and see if my assumptions\nabout the rating system work, or if the system will go bonkers when used in real life!\nOf course, the simulation will represent a simplification of reality:<\/p>\n<ul><li>if the simulation shows bad behaviour, then the system probably won't work in real life; but<\/li>\n<li>if the simulation shows good behaviour, then <em>maybe<\/em> the system will work in real life.<\/li>\n<\/ul><h2 id=\"updating-the-rating\">Updating the rating<a href=\"#updating-the-rating\" class=\"toc-anchor after\" data-anchor-icon=\"#\" aria-label=\"Anchor\"><\/a><\/h2>\n<p>The key thing that I need is the formula to update the rating when two players face each other off.\nIf we scroll the Wikipedia article to the section that mentions the mathematical details,\nwe get what we need.<\/p>\n<p>Suppose that players <span class=\"mathjax mathjax--inline\">\\(A\\)<\/span> and <span class=\"mathjax mathjax--inline\">\\(B\\)<\/span> have ratings <span class=\"mathjax mathjax--inline\">\\(R_A\\)<\/span> and <span class=\"mathjax mathjax--inline\">\\(R_B\\)<\/span>, respectively.\nThe Elo rating system determines how well it <em>thinks<\/em> each player should perform,\nwhen compared to the other player.\nIn other words, the ratings <span class=\"mathjax mathjax--inline\">\\(R_A\\)<\/span> and <span class=\"mathjax mathjax--inline\">\\(R_B\\)<\/span> don't really say how good &ndash; or how bad &ndash;\neach player is; the ratings only say...<\/p>","summary":"Join me as I create a simulation that tries to test an Elo-based rating system for quizzes.","date_modified":"2025-07-23T16:49:02+02:00","tags":["chess","mathematics","programming","python","simulation","streamlit"],"image":"\/user\/pages\/02.blog\/elo-rating-system-simulation\/thumbnail.webp"}]}
