Source:
Harry Crane and Glenn Shafer (2020), Risk is random: The magic of the d’Alembert. https://researchers.one/articles/20.08.00007
Stewart N. Ethier (2010), The Doctrine of Chances Probabilistic Aspects of Gambling. Springer-Verlag: Berlin, Heidelberg.
set.seed(12345)
startKapitaal <- 25
eersteInzet <- 1
noodstopKapitaal <- 15
aantalBeurten <- 21
K <- 100
J <- 200
winsten <- rep(0, K)
for (k in (1:K)){
plot(x = -2, y = -1, ylim = c(-5, 45), xlim = c(0, 22), xlab = "Beurt", ylab = "Kapitaal")
abline(h = 25)
abline(h = 0, col = "red")
aantalKeerWinst <- 0
totaleWinst <- 0
for (j in (1:J)) {
huidigeKapitaal <- startKapitaal
huidigeInzet <- eersteInzet
resultaten <- sample(x = c(-1, +1), prob = c(19, 18), size = aantalBeurten, replace = TRUE)
verloop <- rep(0, aantalBeurten)
stappen <- rep(0, aantalBeurten)
for(i in 1:aantalBeurten) {
huidigeResultaat <- resultaten[i]
if(huidigeInzet > 0){
stap <- huidigeResultaat * huidigeInzet
stappen [i] <- stap
huidigeKapitaal <- huidigeKapitaal + stap
huidigeInzet <- max(1, huidigeInzet - stap)
if(huidigeKapitaal < noodstopKapitaal) {huidigeInzet <- 0}
verloop[i] <- huidigeKapitaal
} else {
stappen[i] <- 0
verloop[i] <- huidigeKapitaal
}
}
aantalKeerWinst <- aantalKeerWinst + (verloop[aantalBeurten] > startKapitaal)
totaleWinst <- totaleWinst + (huidigeKapitaal - startKapitaal)
lines(0:aantalBeurten, c(startKapitaal, verloop) + runif(1, -0.15, +0.15 ), add = TRUE)
}
print(c(k, aantalKeerWinst, totaleWinst))
winsten[k] <- totaleWinst
}
The program repeatedly runs and plots 200 games of each maximally 21 rounds. Below are the total number of times that the player made a profit, and the final net gain, for 100 sets of 200 games. The sets are numbered 1 to 100.
[1] 1 100 -483
[1] 2 108 -336
[1] 3 103 -517
[1] 4 110 -275
[1] 5 123 -40
[1] 6 125 148
[1] 7 115 -209
[1] 8 104 -427
[1] 9 108 -356
[1] 10 110 -225
[1] 11 101 -440
[1] 12 120 80
[1] 13 108 -334
[1] 14 110 -279
[1] 15 99 -538
[1] 16 114 -101
[1] 17 113 -92
[1] 18 117 -87
[1] 19 104 -363
[1] 20 103 -320
[1] 21 114 -52
[1] 22 107 -422
[1] 23 108 -226
[1] 24 115 -173
[1] 25 110 -209
[1] 26 109 -261
[1] 27 114 -186
[1] 28 120 -62
[1] 29 123 35
[1] 30 101 -442
[1] 31 111 -215
[1] 32 104 -378
[1] 33 120 49
[1] 34 117 -49
[1] 35 119 -102
[1] 36 104 -488
[1] 37 107 -402
[1] 38 122 38
[1] 39 100 -549
[1] 40 116 -31
[1] 41 127 220
[1] 42 105 -427
[1] 43 114 -153
[1] 44 109 -256
[1] 45 119 -166
[1] 46 121 47
[1] 47 105 -417
[1] 48 113 -134
[1] 49 121 111
[1] 50 112 -307
[1] 51 114 -92
[1] 52 123 123
[1] 53 118 24
[1] 54 113 -188
[1] 55 124 127
[1] 56 110 -229
[1] 57 113 -255
[1] 58 101 -554
[1] 59 114 -345
[1] 60 124 236
[1] 61 97 -599
[1] 62 115 -220
[1] 63 120 55
[1] 64 102 -512
[1] 65 121 109
[1] 66 112 -219
[1] 67 112 -181
[1] 68 115 -45
[1] 69 107 -474
[1] 70 109 -272
[1] 71 116 -134
[1] 72 107 -440
[1] 73 108 -470
[1] 74 119 -85
[1] 75 115 1
[1] 76 115 -88
[1] 77 113 -219
[1] 78 118 -55
[1] 79 115 -150
[1] 80 124 70
[1] 81 115 -203
[1] 82 115 -153
[1] 83 109 -219
[1] 84 97 -675
[1] 85 108 -396
[1] 86 112 -220
[1] 87 115 -187
[1] 88 108 -290
[1] 89 114 -182
[1] 90 105 -439
[1] 91 113 -183
[1] 92 115 -216
[1] 93 124 110
[1] 94 115 -173
[1] 95 125 177
[1] 96 110 -203
[1] 97 128 160
[1] 98 114 -83
[1] 99 118 -90
[1] 100 123 106