Skip to content
Simulate win probability in tennis match.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


2019ausfinalosaka csv_graph

TennisWinProbSim is python programs for simulate win probability in tennis match. For python3.xx.

Monte Carlo simulation by random number calculation.

You can get the win probability fluctuation chart from point won data.


GIF Animation.

2019ausfinalosaka csv_graph

Input files

  • csvfile

If you want to calculate the simulation,you need to prepare the csv file as below.

(Sample file "2019AusFinalOsaka.csv_output.csv")

Point by point won data which won the point and which server and so on.


In row of FirstSecond,you edit the 1 or 2. At that point,if 1st serve was in,you edit the 1, Else if 1st serve was fault,you edit the 2.

In row of Set,you edit set as that point. In row of Server,At that point,which the serve is. In row of WonA,If playerA got the point,you edit 1. If not,you edit 0.

Output files

If you calc the simulation,you obtain this files.

  • Point by Point WinProbabilitiy data(.csv)
  • Win probability progress chart (.png)
  • Win probability progress chart Gif Animation(.gif)


  • python3
  • pandas
  • numpy
  • matplotlib
  • sys
  • json


  1. Clone this repository to your working directory.

  2. Before simulating,You need to edit the init.json

  • "file" Rewrite the filename of csvfile that is windata point by point

  • "firstsecond" 0:ignore serve 1st2nd 1:serve 1st2nd

  • "playera" "playerb" Rewrite the playerName a and b.This name is needed to match

  • "plength" This simulation is caluculated percentage of point win from last plength points. 30 points is default.

  • "ngames" Number of caluculations.1000 is recommended.

  1. When editing is completed,open this ipynb file on the JupyterNotebook.

If you execute the top script,you can get Point by Point WinProbabilitiy data(.csv)

  1. And if execute the second script,you can get Win probability progress chart (.png)

  2. If execute the third script,you can get Win probability progress chart Gif Animation(.gif)

Related Site



This software is released under the MIT License, see LICENSE.

You can’t perform that action at this time.