class: center, middle, inverse, title-slide # Statistical Thinking using Randomisation and Simulation ## Game simulation and decision theory ### Di Cook (
dicook@monash.edu
,
@visnut
) ### W1.C2 --- # Overview - Decision Theory is concerned with the mathematical analysis of decision making when the __state of the world is uncertain__ but information can be obtained about it by means of observation or experimentation. - Some __action must be chosen__ from a well defined set of alternatives, but the exact circumstances in which the action must be taken are unknown. - Different actions implies different consequences and therefore have different merit according to the decision maker's preference. --- # Overview - Assuming that __some numerical value__ can be assigned to the different combinations of circumstances and actions provides a basis for assessing __how reasonable a particular action is in different situations__. - It may be possible to obtain __data__ that will yield information about the prevailing circumstances, or prior information concerning the __frequency with which different circumstances arise__. - The aim of __decision theory__ is to provide a means of exploiting such information to determine a __reasonable__ (optimal?) __course of action__. --- # Rock, paper, scissors Strategy | Decision | Rock | Paper | Scissors -----|-----|-----|-----|----- `\(a_1\)` | Rock | 0 | -1 | 1 `\(a_2\)` | Paper | 1 | 0 | -1 `\(a_3\)` | Scissors | -1 | 1 | 0 Your choices are `\(a_1, a_2, a_3\)`. Depending on what the opponent chooses you win (1), lose (-1) or tie (0). __What should you choose?__ --- # Decision under ignorance/risk - Decision under __ignorance__: probability of the possible outcomes __unknown or does not exist__ - Decision under __risk__: __probability__ of the possible outcomes __known__ - Decision under uncertainty: synonym for ignorance, or as a broader term referring to both risk and ignorance --- class: inverse middle # Your turn What is rock, paper, scissors? - Decision under risk? - Decision under ignorance? --- # Zero-sum two person games - The payoff is the amount of money each player receives after choosing their respective strategies - Whatever one player loses, the other player wins. - Each player must choose his own strategy without knowing what his opponent is going to do. - An objective is to determine optimal winning strategies. --- # Rock, paper, scissors Strategy | Decision | Rock (1/3) | Paper (1/3) | Scissors (1/3) ----- | ----- | ----- | ----- | ----- `\(a_1\)` | Rock | 0 | -1 | 1 `\(a_2\)` | Paper | 1 | 0 | -1 `\(a_3\)` | Scissors | -1 | 1 | 0 Whatever you choose you have a 1/3 of winning, losing or tieing. --- # Let's simulate the game - Fix your decision to be `\(a_1\)`, without loss of generality - Randomly generate the opponents response - Count the number of times you win, lose, tie Run 1: ``` #> d #> Paper Rock Scissors #> 3236 3419 3345 ``` Run 2: ``` #> d #> Paper Rock Scissors #> 3370 3324 3306 ``` Run 3: ``` #> d #> Paper Rock Scissors #> 3364 3357 3279 ``` There is no optimal strategy. --- # Different probabilities Strategy | Decision | Rock (0.354) | Paper (0.350) | Scissors (0.296) ----- | ----- | ----- | ----- | ----- `\(a_1\)` | Rock | 0 | -1 | 1 `\(a_2\)` | Paper | 1 | 0 | -1 `\(a_3\)` | Scissors | -1 | 1 | 0 But people have some patterns when they play, generally. It is reported that people tend to play rock and paper more than scissors. (Probabilities reported in article in [http://www.telegraph.co.uk](http://www.telegraph.co.uk/men/thinking-man/11051704/How-to-always-win-at-rock-paper-scissors.html)) Check that the probabilities sum to 1. (Why?) Now what should be your strategy? Also, look at this [twitter poll](https://twitter.com/nj_tierney/status/888345405871636480). --- class: inverse middle # Your turn If your strategy is - `\(a_1\)`, - `\(a_2\)`, or - `\(a_3\)`, your chance of winning should be? --- # Let's simulate it - Generate `\(n\)` samples from a `uniform(0,1)` distribution - Bin the number into `0-0.354, 0.354-0.654, 0.654-1` to match the probabilities of opponent choices - Count the proportion of `\(n\)` times you would win under each strategy `\(a_1, a_2, a_3\)`. For each of the following runs, my `\(n=10000\)`. Your strategy is `\(a_1\)`, `Rock`: ``` #> [1] 0.35 ``` Your strategy is `\(a_2\)`, `Paper`: ``` #> [1] 0.36 ``` Your strategy is `\(a_3\)`, `Scissors`: ``` #> [1] 0.3 ``` --- # Pay off matrix, includes opp payoff Strategy | Decision | Rock (0.354) | Paper (0.350) | Scissors (0.296) ----- | ----- | ----- | ----- | ----- `\(a_1\)` | Rock | 0, 0 | -1, 1 | 1, -1 `\(a_2\)` | Paper | 1, -1 | 0, 0 | -1, 1 `\(a_3\)` | Scissors | -1, 1 | 1, -1 | 0, 0 $$\mbox{payoff}|a_1 = 0\times 0.354 - 1\times0.350 + 1\times 0.296 = -0.054 $$ $$\mbox{payoff}|a_2 = 1\times 0.354 + 0\times0.350 - 1\times 0.296 = 0.058 $$ `$$\mbox{payoff}|a_3 = -1\times 0.354 + 1\times0.350 + 0\times 0.296 = -0.004$$` There's a clear winner! --- class: inverse middle # Your turn Under a different payoff? Strategy | Decision | Rock (0.354) | Paper (0.350) | Scissors (0.296) ----- | ----- | ----- | ----- | ----- `\(a_1\)` | Rock | 0, 0 | -1, 1 | 1, -1 `\(a_2\)` | Paper | 2, -1 | -1, 0 | -1, 1 `\(a_3\)` | Scissors | -1, 1 | 1, -1 | 0, 0 - Is it still a zero sum game? - What is the expected payoff under each strategy? --- # Playing until someone loses all their money Suppose you choose strategy `\(a_2\)`, for all your turns. ``` #> $nturns #> [1] 1 #> #> $winnings #> [1] 2 ``` --- # Simulate 100 times <img src="week1.class2_files/figure-html/unnamed-chunk-10-1.png" style="display: block; margin: auto;" /> The expected earnings with strategy `\(a_2\)` is 1.16 (estimated using mean of simulated winnings). --- # Dependency between consecutive games People have a tendency to stay with their previous choice of moves, if they won, otherwise to switch to the what would have been the winning move assuming that the opponent won't change. Using this knowledge, could give you an advantage. We can simulate this too. Let's compare two new strategies for consecutive moves: - `\(a_1\)`: Counter those moves of opponent as above - `\(a_2\)`: Purely random choice of move each time --- Results with strategy 1: ``` #> [1] -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 #> [24] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 #> [47] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 #> [70] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 #> [93] 1 1 1 1 1 1 1 1 ``` Results with strategy 2: ``` #> [1] -1 -1 1 0 0 0 -1 1 1 0 0 -1 -1 1 -1 1 1 0 0 -1 1 1 -1 #> [24] 0 -1 0 0 -1 0 1 0 1 0 -1 1 0 -1 -1 0 -1 1 0 1 -1 -1 1 #> [47] 0 -1 1 0 1 -1 1 1 -1 1 0 1 -1 0 0 1 -1 1 0 0 1 -1 -1 #> [70] 1 1 1 -1 1 1 1 -1 1 -1 1 -1 -1 -1 0 1 1 0 1 -1 1 0 0 #> [93] -1 1 0 -1 -1 0 0 0 ``` Expected winnings, strategy 1 are 0.98, and for stratgey 2 are 0.03. --- # Non-zero sum games Examples: - The prisoner's dilemma - Chicken - Deadlock and stag hunt [Source](https://cs.stanford.edu/people/eroberts/courses/soco/projects/1998-99/game-theory/nonzero.html) --- class: inverse middle # Share and share alike <a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.