Giter Site home page Giter Site logo

ipl's Introduction

IPL

IPL playoff simulator

This is a python based playoff probability simulator. Tested with python 3.8.5 on windows 10 64-bit OS.

Overview of algorithm:

Assuming no ties/washout/no result, each game has two possible outcomes. If n games remain in the tournament, there are a total of 2^n possible scenarios. For each of these scenarios, compute how the final points table will look and from that, one can figure out which teams make it to top 2 spots and which teams makes it to top 4. In the event of multiple teams finishing with same points, NRR comes into play. From this final picture, it can be determined if a team makes it to top 2 confirmed on points alone, top 2 competing on NRR, top 4 confirmed spot and top 4 competing on NRR. Given the 2^n scenarios, if a team makes it to top 2 confirmed spot in say x scenarios, x/(2^n) is the probability of that team making it to top 2 confirmed spot.

How do i simulate the 2^n scenarios?

  • run a loop from 0 to (2^n)-1
  • convert the number to a binary string - this binary sequence will represent a unique sequence of events (eg: 3 games left -> 0 to 7 -> 000, 001, 010, 011, 100, 101, 110, 111 represent the 8 possible scenarios of results, with each digit of the binary number representing the outcome of a single game)
  • if a digit is 0, assume team-1 won that game and if the digit is 1, assume team-2 won and allocate points accordingly

The script takes about ~15 minutes to estimate outcomes for 24 games (16.7 million scenarios). Can it be made more efficient? Definitely yes! I will post an algorithm shared by another reddit user which is more compact and uses recursion, but might be slightly complicated to understand/debug for someone who is not very familiar with recursions.

I prefer the current algorithm as I have tested it for accuracy and its easier to understand and debug for beginner level programmers. Also, the time taken to run the script reduces by 50% with every passing game and therefore once you get to 25 games or less, performance is not a major concern.

ipl's People

Contributors

amerind386 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.