
This article is a beginner level exercise in introductory concepts of probability and simulation design. Lets have some fun with R while learning.
本文是关于概率和模拟设计入门概念的初学者级练习。 让我们边学习边玩R。
The problem statement is as follows…
问题陈述如下……
At the Crown Casino in Melbourne, Australia, some roulette wheels have 18 slots colored red, 18 slots colored black, and 1 slot (numbered 0) colored green. The red and black slots are also numbered from 1 to 36. (Note that some of the roulette wheels also have a double zero, also colored green, which nearly doubles the house percentage.)
在澳大利亚墨尔本的皇冠赌场,一些轮盘赌有18个红色的插槽,18个黑色的插槽和1个绿色的插槽(编号0)。 红色和黑色插槽的编号也从1到36。(请注意,某些轮盘赌轮也具有双零,也呈绿色,这几乎使房屋百分比翻了一番。)
You can play various ‘games’ or ‘systems’ in roulette. Four possible games are:
您可以在轮盘赌中玩各种“游戏”或“系统”。 四种可能的游戏是:
Betting on Red: This game involves just one bet. You bet $1 on red. If the ball lands on red you win $1, otherwise, you lose.
对红色下注:此游戏仅涉及一个下注。 您用红色下注$ 1。 如果球落在红色上,您将赢得$ 1,否则,您将输。
Betting on a Number: This game involves just one bet. You bet $1 on a particular number, say 17; if the ball lands on that number you win $35, otherwise you lose.
下注:这个游戏只涉及一个下注。 您在特定数字上下注$ 1,例如17; 如果球落在该数字上,您将赢得$ 35,否则您将输。
Martingale System: In this game, you start by betting $1 on red. If you lose, you double your previous bet; if you win, you bet $1 again. You continue to play until you have won $10, or the bet exceeds $100.
ting系统:在此游戏中,您从红色下注$ 1开始。 如果输了,则将先前的投注加倍; 如果您赢了,则再次下注$ 1。 您继续玩直到赢得$ 10或下注超过$ 100。
Labouchere System: In this game you start with the list of numbers (1, 2, 3, 4). You bet the sum of the first and last numbers on red (initially $5). If you win you delete the first and last numbers from the list (so if you win your first bet it becomes (2,3)), otherwise you add the sum to the end of your list (so if you lose your first bet it becomes (1, 2, 3, 4, 5)). You repeat this process until your list is empty, or the bet exceeds $100. If only one number is left on the list, you bet that number.
Labouchere系统:在此游戏中,您从数字列表(1、2、3、4)开始。 您用红色下注第一个和最后一个数字的总和(最初为$ 5)。 如果您赢了,则从列表中删除第一个和最后一个数字(因此,如果您赢了第一个赌注,则变为(2,3)),否则,将总和添加到列表的末尾(因此,如果您输掉了第一个赌注,则等于变成(1、2、3、4、5))。 您重复此过程,直到您的列表为空,或赌注超过$ 100。 如果列表上只剩下一个数字,则您下注该数字。
Different games offer different playing experiences; for example, some allow you to win more often than you lose, some let you play longer, some cost more to play, and some risk greater losses. The aim of this article is to compare the four systems on the following criteria:
不同的游戏提供不同的游戏体验; 例如,有些让您获胜的机会多于失败,有些让您玩得更长久,有些让您玩得更多,而有些则冒着更大的损失的风险。 本文的目的是根据以下标准比较这四个系统:
The expected winnings per game
每场比赛的预期奖金
The proportion of games you win
您赢的游戏比例
The expected playing time per game, measured by the number of bets made
每场比赛的预期上场时间,以下注次数衡量
The maximum amount you can lose/win
您可以输/赢的最大金额
Lets look at the betting systems…
让我们看一下下注系统...
System 1 — Betting on Red: This kind of an event is called a ‘Bernoulli Trial’, referring to the definition from Wikipedia
系统1-投注红色:此类事件称为“伯努利审判”,指的是维基百科的定义
In the theory of probability and statistics, a Bernoulli trial is a random experiment with exactly two possible outcomes, “success” and “failure”, in which the probability of success is the same every time the experiment is conducted.
在概率论和统计理论中,伯努利试验是一项随机试验,恰好有两个可能的结果,即“成功”和“失败”,其中每次进行成功的概率都是相同的。
In this case, winning is defined as an event where the ball lands on any slot with red color.
在这种情况下,获胜被定义为球落在任何红色插槽上的事件。
Part 1: Let's calculate the theoretical probability for the amount won when this system is incorporated to play the game.
第1部分:让我们计算将这个系统整合到游戏中后所赢得金额的理论概率。

Where 18/37 is the probability of winning, 19/37 is the probability of losing (we lose if ball lands in any of the 18 black slots and 1 green slot), $1 and -$1 are the amount gained in a scenario of a win/loss respectively.
其中18/37是获胜的概率,19/37是获胜的概率(如果球落在18个黑色插槽和1个绿色插槽中的任何一个中,则我们会损失),$ 1和-$ 1是在以下情况下获得的金额:分别赢/输。
PS: Negative dollar indicates money lost when you loose the bet.
PS:负数美元表示您失去赌注时会损失金钱。
This means you lose ($0.027) every time you play. (surprise, surprise) This also shows us that if you play the game long enough, you are bound to loose money at the Casino. That’s why Stat Major should refrain from gambling.
这意味着您每次玩游戏都会损失($ 0.027)。 (使人惊讶)这也向我们表明,如果您玩了足够长时间的游戏,您肯定会在赌场损失钱财。 这就是为什么Stat Major应该避免赌博。
Simulation design process: Idea here is to play this virtually 100000 times and check if our theoretical results match with the experiment and check other interesting facts about betting this way.
模拟设计过程:这里的想法是实际上进行100000次,并检查我们的理论结果是否与实验相符,并检查有关此方式下注的其他有趣事实。
Simulation Design Objectives :
仿真设计目标:
- Design a function which plays the roulette game (ODDS of winning18/37) 设计一个玩轮盘游戏的功能(ODDS赢得18/37)
- Play this game 100000 times and return the amount won 玩此游戏100000次,并返回赢取的金额
- Sum these winnings from the simulated games.将模拟游戏中的这些奖金相加。
Simulation results for System 1:
系统1的仿真结果
Mean of amount won after 100000 trials: -0.02642 (Code in appendix)
100000次试用后获胜的平均值:-0.02642(附录中的代码)
Comparing the theoretical results vs experimental results:
比较理论结果与实验结果:

Percentage of error=2.14%
误差百分比= 2.14%
This means our experiment stands corrected, if we play this game long enough we see the mean of total amount won converges towards the theoretically proposed value.
这意味着我们的实验已得到纠正,如果我们玩这个游戏足够长时间,我们会看到获胜总额的平均值收敛到理论上建议的值。
Part 2: Proportion of wins: Number wins for this game will be theoretically equal to
第2部分:获胜比例:这场比赛的获胜人数理论上将等于

Simulation estimate for 100000 trials: 0.48651 (Code in appendix)
100000次试验的模拟估算值:0.48651(附录中的代码)
Percentage error = -0.0061%
百分比误差= -0.0061%
Part 3: Expected playing time = 1 bet (game only lasts 1 bet as per description in question statement)
第3部分:预期比赛时间= 1下注(根据问题陈述中的描述,游戏仅持续1下注)
Part 4: Maximum money player can lose/win = $1 (By game design) This system will only last 1 cycle.
第4部分:根据玩家的设计,玩家可以输/赢的最大金额= $ 1(根据游戏设计)此系统仅持续1个周期。
Let's look at Betting system 2 (Betting on a number)…
让我们看一下下注系统2(对数字下注) …
Key difference in this scenario, you only win the game if the ball lands on the number you bet on. This means 1/37 chance of winning a game (you can place bets on any number expect 0)
在这种情况下,关键的区别是,只有当球落在您下注的数字上时,您才能赢得比赛。 这意味着有1/37获胜的机会(您可以对期望为0的任何数字下注)
The amount won also changes to $35 that means if you bet on number 7 and ball lands on it, your original bet of $1 yields winnings of $35 dollars.
获胜金额也将更改为$ 35,这意味着如果您押注第7位并且球落在其上,则原来的$ 1押注会产生$ 35美元的赢利。
If you guys are still with me the below calculation should be intuitive:
如果你们还是和我在一起,那么下面的计算应该很直观:
Part 1: Let’s calculate the theoretical probability for the amount won when this game is played
第1部分:让我们计算玩此游戏时赢得金额的理论概率

Where 1/37 is the probability of winning, $35 amount won, 36/37 is the probability of losing,-$1 is the money lost.
其中1/37是获胜的概率,$ 35获胜的金额,36/37是损失的概率,-$ 1是损失的钱。
Simulation results for mean amount won after 100000 trials = -0.0265
100000次试验后赢得的平均金额的模拟结果= -0.0265

Percentage error = 1.85%
百分比误差= 1.85%
Part 2: Proportion of wins: Theoretically the proportion of winning can be given by
第2部分:获胜的比例:理论上,获胜的比例可以由

Simulation results for number of games won after 100000 trials: 0.02584 (Percentage error 4.296%)
在100000次试验后赢得的游戏数量的模拟结果:0.02584(百分比误差4.296%)
Part 3: Playing time is 1 bet
第3部分:上场时间为1下注
Part 4: Max amount which can be lost is $1
第4部分:可以损失的最大金额为$ 1
Part 5: Max amount which can be won is $35
第5部分:可赢取的最高金额为$ 35
Lets look at betting system 3, Martingale betting.
让我们看一下下注系统3,Mar游戏。
Recall that In this system of you start by betting $1 on red. If you lose, you double your previous bet; if you win, you bet $1 again. You continue to play until you have won $10, or the bet exceeds $100.
回想一下,在此系统中,您将$ 1押在红色上。 如果输了,则将先前的投注加倍; 如果您赢了,则再次下注$ 1。 您继续玩直到赢得$ 10或下注超过$ 100。
We have introduced some system constraint to mimic real life situation i.e no one has infinite money and second there are actual betting caps in casinos limiting the maximum amount any player can bet, to discourage mis-use of this strategy.
我们引入了一些系统约束来模拟现实生活中的情况,即没有人拥有无限的金钱,其次赌场中有实际的投注限额限制了任何玩家可以下注的最大金额,以阻止误用此策略。
We don’t have a theoretical expectation of the amount won so let’s look at the results from simulation
我们对赢取金额没有理论上的期望,所以让我们看一下模拟结果
Part 1: Mean amount won during simulation of 100000 trials = -$1.82907
第1部分:在模拟100000次试用期间赢得的平均金额= -$ 1.82907
Part 2: Proportion of wins = 0.9138 (This means you have 91.38% chance of winning a game if you use this strategy!!!!)
第2部分:获胜比例= 0.9138 (这意味着如果您使用此策略,您就有91.38%的机会赢得比赛!!!)
Part 3: Expected playing time by simulation = 16 (1 game lasts 16 consecutive bets on average)
第3部分:通过模拟获得的预期上场时间= 16(1个游戏平均可持续16次连续下注)
Part 4: Maximum amount player can lose = $127
第4部分:玩家可以损失的最高金额= 127美元
Consecutive losses starts -1 -2 -4 -8 -16 -32 -64 = -$127 (Bad luck hits harder)
连续损失开始-1 -2 -4 -8 -16 -32 -64 =-$ 127(运气不好)
Part 5: Maximum amount won: $10 (by design as an exit case scenario, in real life we can change this to any amount which a player might feel confident about and stop betting after achieving that goal)
第5部分:最高获胜金额:10美元(根据实际情况设计,在现实生活中,我们可以将其更改为玩家可能对此有信心并在达到该目标后停止下注的任何金额)
Lets look at the final betting technique Labouchere betting system
让我们看一下最终的投注技术Labouchere投注系统
Recall that, In this game you start with the list of numbers (1, 2, 3, 4). You bet the sum of the first and last numbers on red (initially $5). If you win you delete the first and last numbers from the list (so if you win your first bet it becomes (2,3)), otherwise you add the sum to the end of your list (so if you lose your first bet it becomes (1, 2, 3, 4, 5)). You repeat this process until your list is empty, or the bet exceeds $100. If only one number is left on the list, you bet that number.
回想一下,在这个游戏中,您从数字列表(1、2、3、4)开始。 您用红色下注第一个和最后一个数字的总和(最初为$ 5)。 如果您赢了,则从列表中删除第一个和最后一个数字(因此,如果您赢了第一个下注,则变为(2,3)),否则,将总和添加到列表的末尾(因此,如果您输掉了第一个下注,变成(1、2、3、4、5))。 您重复此过程,直到您的列表为空,或赌注超过$ 100。 如果列表上只剩下一个数字,则您下注该数字。
Looks a bit complicated but simple strategy, who might use it you ask…no idea! But let’s explore the statistical idea behind the process
看起来有点复杂但简单的策略,您可能会问谁使用它……不知道! 但是,让我们探索该过程背后的统计思想
Part 1: Mean amount won as per simulation of 100000 = $-3.32318
第1部分:根据模拟得出的平均获胜金额100000 = $ -3.32318
Part 2: Proportion of wins by simulation = 0.95636 or 95.636% (And you thought 91% in Martingale was as high we can go? This system increases our proportion by an additional 4%)
第2部分:通过模拟得出的获胜比例= 0.95636或95.636%(您认为Martingale中的91%是我们可以达到的最高水平?此系统将我们的比例增加了4%)
Part 3: Expected playing time by simulation = 4 (Average game lasts 4 consecutive bets)
第3部分:通过模拟获得的预期比赛时间= 4(平均游戏持续4次连续下注)
Part 4: Maximum amount of money player can lose = $4940
第4部分:玩家可以损失的最高金额= $ 4940
Consecutive loses since start -5 -6 -7 -8…..- 99 = -$4940
自开局以来连续亏损-5 -6 -7 -8…..- 99 =-$ 4940
Part 5: Maximum amount of money player can earn =$10
第5部分:玩家可以赚取的最高金额= $ 10
Some graphs to put all the numbers into perspective
一些图表将所有数字都放在透视图中
Amount lost per game: tableau link
每场比赛损失的数量: Tableau链接

Proportion of winning a game: Tableau link
赢得比赛的比例: Tableau链接

Standard deviation of amount lost: Tableau link
损失金额的标准差: Tableau链接

Playing time for 1 game (Consecutive bets): Tableau link
1场比赛的上场时间(连续投注): Tableau链接

So to conclude, you still lose money even if you manage to win individual bets in a roulette game if you play long enough the house is the only one standing….
综上所述,即使您玩了足够长的时间,即使您设法在轮盘游戏中赢得个人下注,您仍然会赔钱。
Simulation Code: https://github.com/sedhasukhdeep/Roulette-Simulation
仿真代码: https : //github.com/sedhasukhdeep/Roulette-Simulation
翻译自: https://medium.com/swlh/simulating-roulette-strategies-in-r-461d6a1db2fd