Analyzing a Tennis Game with Markov Chains

Similar documents
Chapter 35 out of 37 from Discrete Mathematics for Neophytes: Number Theory, Probability, Algorithms, and Other Stuff by J. M. Cargal.

Markov Chains. As part of Interdisciplinary Mathematical Modeling, By Warren Weckesser Copyright c 2006.

33 The Gambler's Ruin 1

ECE 302: Chapter 02 Probability Model

The Boundary Problem: Markov Chain Solution

Markov Processes Hamid R. Rabiee

CHAPTER 6. Markov Chains

Page Max. Possible Points Total 100

Discrete distribution. Fitting probability models to frequency data. Hypotheses for! 2 test. ! 2 Goodness-of-fit test

MATH 3C: MIDTERM 1 REVIEW. 1. Counting

Introduction to Probability 2017/18 Supplementary Problems

ECE 541 Project Report: Modeling the Game of RISK Using Markov Chains

IEOR 3106: Introduction to Operations Research: Stochastic Models. Professor Whitt. SOLUTIONS to Homework Assignment 1

CS 361: Probability & Statistics

Chapter 10. Finite-State Markov Chains. Introductory Example: Googling Markov Chains

The probability of an event is viewed as a numerical measure of the chance that the event will occur.

New Topic. PHYS 1021: Chap. 10, Pg 2. Page 1

MAS275 Probability Modelling Exercises

Lecture 6 - Random Variables and Parameterized Sample Spaces

Computations - Show all your work. (30 pts)

Independent Events. The multiplication rule for independent events says that if A and B are independent, P (A and B) = P (A) P (B).

Hidden Markov Models

8. MORE PROBABILITY; INDEPENDENCE

Math 180B Problem Set 3

MAT Mathematics in Today's World

2. A SMIDGEON ABOUT PROBABILITY AND EVENTS. Wisdom ofttimes consists of knowing what to do next. Herbert Hoover

Expected Value II. 1 The Expected Number of Events that Happen

Homework set 2 - Solutions

Probability. VCE Maths Methods - Unit 2 - Probability

Exam 1 Solutions. Problem Points Score Total 145

Massachusetts Institute of Technology

Expected Value 7/7/2006

MATH 19B FINAL EXAM PROBABILITY REVIEW PROBLEMS SPRING, 2010

1.3 Convergence of Regular Markov Chains

Math 416 Lecture 3. The average or mean or expected value of x 1, x 2, x 3,..., x n is

Some Definition and Example of Markov Chain

Week 3 Sept. 17 Sept. 21

Topics in Probability Theory and Stochastic Processes Steven R. Dunbar. Binomial Distribution

Grades 7 & 8, Math Circles 24/25/26 October, Probability

Discrete Random Variables. Discrete Random Variables

RISKy Business: An In-Depth Look at the Game RISK

Second Problem Assignment

Name: 180A MIDTERM 2. (x + n)/2

May 2015 Timezone 2 IB Maths Standard Exam Worked Solutions

1 More finite deterministic automata

UCSD CSE 21, Spring 2014 [Section B00] Mathematics for Algorithm and System Analysis

3. A square has 4 sides, so S = 4. A pentagon has 5 vertices, so P = 5. Hence, S + P = 9. = = 5 3.

Probability Theory and Applications

Discrete Applied Mathematics

Markov Chains. CS70 Summer Lecture 6B. David Dinh 26 July UC Berkeley

Lecture 10: Probability distributions TUESDAY, FEBRUARY 19, 2019

NAME (1 pt): TA (1 pt): Name of Neighbor to your left (1 pt): Name of Neighbor to your right (1 pt):

Econ 371 Problem Set #1 Answer Sheet

N/4 + N/2 + N = 2N 2.

Simple Consumption / Savings Problems (based on Ljungqvist & Sargent, Ch 16, 17) Jonathan Heathcote. updated, March The household s problem X

Simultaneous Equations Solve for x and y (What are the values of x and y): Summation What is the value of the following given x = j + 1. x i.

STAT 285 Fall Assignment 1 Solutions

What is Probability? Probability. Sample Spaces and Events. Simple Event

Monty Hall Puzzle. Draw a tree diagram of possible choices (a possibility tree ) One for each strategy switch or no-switch

SIMPLE RANDOM WALKS: IMPROBABILITY OF PROFITABLE STOPPING

COS 341: Discrete Mathematics

Math 151. Rumbos Fall Solutions to Review Problems for Exam 2. Pr(X = 1) = ) = Pr(X = 2) = Pr(X = 3) = p X. (k) =

Markov Chains. Chapter Introduction. 1. w(1) = (.5,.25,.25) w(2) = (.4375,.1875,.375) w(3) = (.40625, , ) 1 0.

NANYANG TECHNOLOGICAL UNIVERSITY SEMESTER I EXAMINATION MH4702/MAS446/MTH437 Probabilistic Methods in OR

Lectures on Markov Chains

AP Statistics Semester I Examination Section I Questions 1-30 Spend approximately 60 minutes on this part of the exam.

CS 125 Section #12 (More) Probability and Randomized Algorithms 11/24/14. For random numbers X which only take on nonnegative integer values, E(X) =

Discrete Mathematics and Probability Theory Spring 2016 Rao and Walrand Note 14

Markov Chains Absorption Hamid R. Rabiee

Lecture 5: Introduction to Markov Chains

Chapter 7: Section 7-1 Probability Theory and Counting Principles

Exam 2 Review Math 118 Sections 1 and 2

Question 2 We saw in class that if we flip a coin K times, the the distribution in runs of success in the resulting sequence is equal to

CHAPTER 3 PROBABILITY TOPICS

Please simplify your answers to the extent reasonable without a calculator. Show your work. Explain your answers, concisely.

Weather Overnight. Income (I) Running total

Lecture 23: More PSPACE-Complete, Randomized Complexity

Midterm Exam 1 (Solutions)

Discrete Mathematics for CS Spring 2007 Luca Trevisan Lecture 20

Lecture 3. January 7, () Lecture 3 January 7, / 35

Math , Fall 2012: HW 5 Solutions

M118 Exam Jam. Contents. Chapter 2: Set Theory 2. Chapter 3: Combinatorics 5. Chapter 4: Probability 7. Chapter 5: Statistics 12

Today. Next lecture. (Ch 14) Markov chains and hidden Markov models

Tail Inequalities. The Chernoff bound works for random variables that are a sum of indicator variables with the same distribution (Bernoulli trials).

NORTHWESTERN UNIVERSITY Tuesday, Oct 6th, 2015 ANSWERS FALL 2015 NU PUTNAM SELECTION TEST

V. RANDOM VARIABLES, PROBABILITY DISTRIBUTIONS, EXPECTED VALUE

DRAFT. M118 Exam Jam Concise. Contents. Chapter 2: Set Theory 2. Chapter 3: Combinatorics 3. Chapter 4: Probability 4. Chapter 5: Statistics 6

Catch-Up: A Rule That Makes Service Sports More Competitive

Markov Chains and Related Matters

STA 247 Solutions to Assignment #1

Chapter 10 Markov Chains and Transition Matrices

Lecture 3 Probability Basics

Recitation 6. Randomization. 6.1 Announcements. RandomLab has been released, and is due Monday, October 2. It s worth 100 points.

ENGR 200 ENGR 200. What did we do last week?

Universality for mathematical and physical systems

CSE 312: Foundations of Computing II Quiz Section #10: Review Questions for Final Exam (solutions)

Chapter 2: Set Theory 2. Chapter 3: Combinatorics 3. Chapter 4: Probability 4. Chapter 5: Statistics 5

Solutions to In Class Problems Week 12, Wed.

Mean/Average Median Mode Range

Sample Space: Specify all possible outcomes from an experiment. Event: Specify a particular outcome or combination of outcomes.

Transcription:

Analyzing a Tennis Game with Markov Chains What is a Markov Chain? A Markov chain is a way to model a system in which: 1) The system itself consists of a number of states, and the system can only be in one state at any time. This is often viewed as the system moving in discrete steps from one state to another. 2) The probability that the system will move between any two given states is known. These probabilities are usually given as a matrix, where row i of the matrix is the list of probabilities of moving from state i to any other state. Once the matrix for a Markov chain is known it can be used to find all sort of probabilities, including the probability that the system will be in any given state after a given number of steps, the number of steps it will take on average to move from one given state to another, and the probability that the system will end up in a given state in the long run. A simple example of a Markov chain is a coin flipping game. Let s say we have a coin which has a 45% chance of coming up Heads and a 55% chance of coming up tails. I win the game if the coin comes up Heads twice in a row and you will win if it comes up Tails twice in a row. In terms of playing the game since we are only interested in getting two heads/tails we only need to track what the coin was on the last flip. This means the game has 5 states: State 1: The start (we haven t flipped the coin yet) State 2: Heads was the previous flip. State 3: Tails was the previous flip. State 4: I won the game. State 5: You won the game. The probability table for this process looks like this: Entering this as a matrix we have: Start Heads Tails I win You win Start 0 0.45 0.55 0 0 Heads 0 0 0.55 0.45 0 Tails 0 0.45 0 0 0.55 I win 0 0 0 1 0 You win 0 0 0 0 1

2 Tennis.nb flipmatrix = 0 0.45 0.55 0 0 0 0 0.55 0.45 0 0 0.45 0 0 0.55 0 0 0 1 0 0 0 0 0 1 ; In Mathematica we can now describe the game using DiscreteMarkovProcess, letting the computer know the game starts in state 1: coinprocess = DiscreteMarkovProcess[1, flipmatrix] DiscreteMarkovProcess[1, {{0, 0.45, 0.55, 0, 0}, {0, 0, 0.55, 0.45, 0}, {0, 0.45, 0, 0, 0.55}, {0, 0, 0, 1, 0}, {0, 0, 0, 0, 1}}] Before we do any calculations we can have Mathematica show us the graph of how the system moves from state to state: Graph[ coinprocess, VertexLabels Thread[Range[5] coinstates], ImageSize 500, EdgeLabels Getedges[flipmatrix], VertexSize Medium] Now we can see the chance that I will win in 4 flips or less: PDF[coinprocess[4], 4] 0.363994 The chance that I will win in any number of flips: PDF[coinprocess[ ], 4] 0.41711 How long on average it takes me to win Mean[ FirstPassageTimeDistribution[ coinprocess, 4]] 3.01265 How long on average it takes you to win: Mean[ FirstPassageTimeDistribution[ coinprocess, 5]] 2.96815 We could even do this for an arbitrary Heads probability. In this case the probability matrix looks like this:

Tennis.nb 3 Clear[p] flipmatrix2 = 0 p 1 - p 0 0 0 0 1 - p p 0 0 p 0 0 1 - p 0 0 0 1 0 0 0 0 0 1 We can now get an exact formula for what my chances of winning are: newcoinprocess = DiscreteMarkovProcess[1, flipmatrix2]; headswins = Simplify[PDF[ newcoinprocess[ ], 4]] (- 2 + p) p2-1 - p + p 2 Graphing this as the probability p goes from 0 to 1 looks like: ; Plot[ headswins, {p, 0, 1}, AxesLabel Text / @ {"Heads probability", "Heads win probability"}] Heads win probability 1.0 0.8 0.6 0.4 0.2 0.2 0.4 0.6 0.8 1.0 Heads probability If I want to figure out how I need to bias the coin to win 3 times out of 4 I can use Reduce: Reduce[ headswins 3 / 4 0 p 1, p, Reals] p Root 3-3 #1-5 #1 2 + 4 #1 3 &, 2 N[%, 10] p 0.6581690825 So if I can bias the coin to come up heads 65.82% of the time I ll have more than 75% chance of winning the game. A Tennis Game as a Markov Chain To describe a tennis game as a Markov chain we need to define both the states and the probability to move between states. There are two states for each score (one for no faults and one for a single fault) together with Win states for players A (the server) and B - for a total of 32 states:

4 Tennis.nb states = {"{0, {0, 0}}", "{0, {0, 15}}", "{0, {0, 30}}", "{0, {0, 40}}", "{0, {15, 0}}", "{0, {15, 15}}", "{0, {15, 30}}", "{0, {15, 40}}", "{0, {30, 0}}", "{0, {30, 15}}", "{0, {40, 0}}", "{0, {40, 15}}", "{0, Deuce}", "{1, {0, 0}}", "{1, {0, 15}}", "{1, {0, 30}}", "{1, {0, 40}}", "{1, {15, 0}}", "{1, {15, 15}}", "{1, {15, 30}}", "{1, {15, 40}}", "{1, {30, 0}}", "{1, {30, 15}}", "{1, {40, 0}}", "{1, {40, 15}}", "{1, Deuce}", "{0, A Adv.}", "{1, A Adv.}", "{0, B Adv.}", "{1, B Adv.}", "A win", "B win"}; The chance to move from any fault/score combination to any other can be described by 4 probabilities (all from 0 to 1): f 1 : The chance Player A faults on the first serve p 1 : The chance Player A will win the point if the first serve is in f 2 : The chance Player A will fault on a second serve p 2 : The chance Player A will win the point on the second serve This leads to a 32-by-32 matrix whose entries involve f 1, p 1, f 2, and p 2 and are often 0: tennismatrix = 0 1 - f1 - (1 - f1) p1 0 0 (1 - f1) p1 0 0 0 0 0 1 - f1 - (1 - f1) p1 0 0 (1 - f1) p1 0 0 0 0 0 1 - f1 - (1 - f1) p1 0 0 (1 - f1) p1 0 0 0 0 0 0 0 0 (1 - f1) p1 0 0 0 0 0 1 - f1 - (1 - f1) p1 0 0 0 0 0 0 0 0 1 - f1 - (1 - f1) p1 0 0 0 0 0 0 0 0 1 - f1 - (1 - f1) p1 0 1 - (1 - f2) p2 0 0 (1 - f2) p2 0 0 0 0 0 1 - (1 - f2) p2 0 0 (1 - f2) p2 0 0 0 0 0 1 - (1 - f2) p2 0 0 (1 - f2) p2 0 0 0 0 0 0 0 0 (1 - f2) p2 0 0 0 0 0 1 - (1 - f2) p2 0 0 0 0 0 0 0 0 1 - (1 - f2) p2 0 0 0 0 0 0 0 0 1 - (1 - f2) p2 Here is the graph of the states in the chain:

Tennis.nb 5 Just as before we can set up the chain in Mathematica using DiscreteMarkovProcess (starting with state 1) and find the probability that Player A will win the game (state 31): tennisprocess = DiscreteMarkovProcess[1, tennismatrix]; chanceforservertowin = Simplify[PDF[tennisprocess[ ], 31]] ((- 1 + f1) p1 + f1 (- 1 + f2) p2) 4 15 + 8 (- 1 + f1) 3 p1 3 + 34 f1 (- 1 + f2) p2 + 28 f1 2 (- 1 + f2) 2 p2 2 + 8 f1 3 (- 1 + f2) 3 p2 3 + 4 (- 1 + f1) 2 p1 2 (7 + 6 f1 (- 1 + f2) p2) + 2 (- 1 + f1) p1 17 + 28 f1 (- 1 + f2) p2 + 12 f1 2 (- 1 + f2) 2 p2 2 1 + 2 (- 1 + f1) 2 p1 2 + 2 f1 (- 1 + f2) p2 + 2 f1 2 (- 1 + f2) 2 p2 2 + 2 (- 1 + f1) p1 (1 + 2 f1 (- 1 + f2) p2) Looking at a specific example, suppose one player has fault chances of 39% and 9%, with chances of winning the points of 68% and 58%. Then the chances that player will win when serving is: chanceforservertowin /. {f1.39, f2.09, p1.68, p2.58} 0.777097

6 Tennis.nb Suppose the other player has fault chances of 25% and 7% with winning chances of 59% and 37%. The chance that the second player will win when serving will then be: chanceforservertowin /. {f1.25, f2.07, p1.59, p2.37} 0.570966 The chance that the first player will win when the second player was serving is then 1 - % 0.429034 Over the summer both had a series of games where each served 18 times. The model predicts how many games the first player will win: 0.777097 * 18 +.429034 * 18 21.7104 And in fact the first player won 22 times. We can also model how long each game would be. When our server had fault chances of 39% and 9% and win chances of winning the points of 68% and 58%. When the server wins the average number of serves in the game would be: Mean[ FirstPassageTimeDistribution[ DiscreteMarkovProcess[1, Evaluate[tennismatrix /. {f1 39 / 100, f2 9 / 100, p1 68 / 100, p2 58 / 100}]], 31]] / / N 8.60193 If the same server were to lose the game, the average game time would be Mean[ FirstPassageTimeDistribution[ DiscreteMarkovProcess[1, Evaluate[tennismatrix /. {f1 39 / 100, f2 9 / 100, p1 68 / 100, p2 58 / 100}]], 32]] / / N 9.74636 Some analysis Now that we have a formula we can ask some general questions about how to improve a player s chance to win a game. Suppose you can practice to improve your scores on any of the four values - can you tell how to practice to get the most benefit? This involves taking various derivatives of the win formula and seeing under what conditions the derivative for one variable is larger than the derivative for another. These inequalities get very complex, so it s useful to have the computer simplify them under the assumotion that the range of values for the probabilities is (0,1): range = 0 < f1 < 1 0 < f2 < 1 0 < p1 < 1 0 < p2 < 1; Comparing the benefit gained from improving your chances of winning on the first serve as opposed to winning on the second:

Tennis.nb 7 Simplify[ Reduce[ D[ chanceforservertowin, p1] > D[chanceforservertowin, p2], {f1, f2, p1, p2}, Reals], range] 1 f1 + f2 > 2 So it s better to practice winning on the first serve if 1 + f f 2 > 2. We can graph this to see what ranges of values 1 make practicing the first point better: RegionPlot 1 + f2 > 2, {f1, 0, 1}, {f2, 0, 1}, PlotRangePadding 0, f1 FrameLabel {"Fault 1 chance", "Fault 2 chance"}, PlotLabel "When is it better to practice winning on the first serve?" Notice that it s always better to practice winning on the first serve over the second if the fault value f 1 1 2 ; for values of f 1 larger than 1 2 it can still be better provided the fault value f 2 is large enough. Is it better to practice not faulting on the second serve or winning on that second serve? Note because we are decreasing the chance to fault we need a - on that derivative Simplify[ Reduce[ - D[ chanceforservertowin, f2] > D[chanceforservertowin, p2], {f1, f2, p1, p2}, Reals], range] f2 + p2 > 1 It turns out it s better to practice not faulting on the second serve only when the sum of the chances to fault on serve 2 and win on serve 2 is greater than one. Author: Dr. Christopher Moretti Revision Date: August 3, 2015