Martingale simulation#

from roulette import Roulette
from core import *
from simulations_core import *
from simulations_plots_core import *
roulette = Roulette()

The Martingale system is a betting strategy based on recovering your losses. The idea is that with every losing roulette spin, you double your wager. In theory, this means that if you eventually win again, you’ll recover any previous losses plus gain a small profit.

def martingale_betting(goal_money_won, bet, money_limit):
    return goal_money_betting_even_bet(roulette, goal_money_won, bet, lambda bet_history : (bet_history[-1]*2, bet_history), 
                                        lambda bet_history : (1, bet_history), money_limit = money_limit)
money_histories = simulate_different_goal_money(
                    betting_type = martingale_betting, 
                    goal_money_list = [10, 100, 500, 1000], 
                    number_histories = 100,
                    start_bet= 1,
                    money_limit=None)

Analysis when the goal is to win 10 units#

mean_money_list, std_money_list = get_mean_and_std_of_histories(money_histories, 10)
plot_money_history(mean_money_list, std_dev=std_money_list, title='Simulations mean and std', log_values=True)
../_images/f40216bb8d97bc507b439043ada6161dcf9c59032ad575ccf89b1705e25f1a6a.png
plot_money_histories(money_histories, 10)
../_images/912cbac6f09cf19fdc12659097e9a182c45b4fdeda1f69d1021fa88df0144dc3.png ../_images/399d7bacc9a74d310c0b8d44a3c7360172980dfbdcd7c4c6b06500035df3e6c0.png ../_images/279db7d9180c3cfecd545640a46b870b01aee64185baec5627bcce2e29ffa590.png ../_images/2435d0e198f8f8926d78b2c91623d6471677ccaae3da913ea8f58167893ed506.png ../_images/b8624092dc4f63f32e30c20bb34e45ccc436976ebcf98c27bb2efd068af65df1.png ../_images/17894cb5bd81d9b63d7275f465dedcb71c004c82bbf8657d7e735c7249e82a51.png ../_images/162647bc8e66542183aa2e9fbe5b8e3a79918fecada5c637faf6e025e4f3700d.png ../_images/6494a245c8bd788a993e31b0fddc08135858d9267a998ffca9acc1f8a61fae45.png ../_images/e6ba7d94ac529d44fed7d39209959b8c9584a00beb7bcad3a9122d678405f290.png ../_images/fd20876668e864ea2e68b3c8b23fe3b099f4d7f492e957b3272ce337ad68683e.png
plot_minimum_money(money_histories, 10, log_values= True)
../_images/379bf02cfd91438fb0751374d5cd36ee94fc099e43672b81013b014dd5ad961e.png

Analysis when the goal is to win 100 units#

mean_money_list, std_money_list = get_mean_and_std_of_histories(money_histories, 100)
plot_money_history(mean_money_list, std_dev=std_money_list, title='Simulations mean and std', log_values=True)
../_images/d721cfb212114631879f46ce5b6813c2031891a699aff6046998ade6dab7ca6d.png
plot_money_histories(money_histories, 100)
../_images/c17d15c2dbe21a5c427d9171496a51bda4d774a158cfcefc9981043f57e913b5.png ../_images/3858da348dfcf73bf5b15277c823106d4a9c8c09e29410ddfdf005c806b55082.png ../_images/bc217b3c10bc5daff431cf6d956a7b706ae9d46cf6ff06b6a0863d0ea19e9224.png ../_images/d8c7952e300f90c68cb0e91b3bddf5679e378b54f4e5e40a461723015d911e40.png ../_images/066cbfcf730055aad2c6d6a55365330260de780d261dea69deba69f979fa79a2.png ../_images/6f97896b704745bacb85b8f17dcc38f171fe3d67b904dbb2bf7de53f46d2c8c2.png ../_images/fd0b699b9492dee655859432f71e88ccca2b2c8d01827f1f4da8b4960e86c8a8.png ../_images/dbef511c19f1edebaf8c7ec2652230d9a3d2d58a348d34ec34058c4cf864f65b.png ../_images/14f7b013ba6d22ebda82efb67183a76bae0dd0aa97ff7b5c34b789cc1d56a5f2.png ../_images/11a9246c95ec0356284f6504e36669700d9282e88f413088136055efe4dd9742.png
plot_minimum_money(money_histories, 100, log_values=True)
../_images/1f17a1d1e7e1f3650c146c1f2dd1bf2dc949caa885204c408839c2cd4ef03beb.png

Analysis when the goal is to win 500 units#

mean_money_list, std_money_list = get_mean_and_std_of_histories(money_histories, 500)
plot_money_history(mean_money_list, std_dev=std_money_list, title='Simulations mean and std', log_values=True)
../_images/17f5a3c5d55d9191554d66a115162a48a79161e915c67adb1bc002f6298c7147.png
plot_money_histories(money_histories, 500)
../_images/1226c09c8b4b1d8fd48b76c2a8f18f2d77d98bceff05de1c9e78a8f73cdb004c.png ../_images/600b1077ed59a2ff1c527962e7f385e322912831cfb90e276464033c4500ee53.png ../_images/57f4d2c10f9fd64c3933dbdaea2db36a8351427363e87b00ccad807311aa6113.png ../_images/693e1d98b5fd1d86429cdc6bfb438061fdb2f88beff82b4867ac51a624924374.png ../_images/2f2da8e60437fb519c82981a6f1c0b855346ec2c354ed9d8bacc66fd16d64e92.png ../_images/7b22901e86d4a429f7c54db58333df52249c885880a1917e4dc9216f6d3c089a.png ../_images/9c176565f3cc7203bbae5221d33d1aecd68e1ca8af4b6e04a3e0d7664d20ed0a.png ../_images/5f1f30855e210bd22c39cedd40deca60fb623acc19075e5d2a3c1b37d6d183b4.png ../_images/2980da8f2359069d6e8fddd9b83f786a9889148719a6be2e0d9e628e0d69b5b1.png ../_images/9b7afb556e7a4c356d6f678317f0d2958828d89b846c4bbff0fdb66891a5fcd0.png
plot_minimum_money(money_histories, 500, log_values=True)
../_images/b4ac97712c6474352e58cbe7646c48c76c7e151b351f56ce8412da0f4d96d1b6.png

Analysis when the goal is to win 1000 units#

mean_money_list, std_money_list = get_mean_and_std_of_histories(money_histories, 1000)
plot_money_history(mean_money_list, std_dev=std_money_list, title='Simulations mean and std', log_values=True)
../_images/67f58ebe3e7ac187f2e4a4b38993b45b627aaab83da5ef030f83173d4b413281.png
plot_money_histories(money_histories, 1000)
../_images/9e63b03a1b79d90498d1703867631df9c4272e13664d0174febc9c6a34622e8f.png ../_images/416b13bbc78f8a4993e9523e45fa8d6794bee6b53b84de6a31355c66506c2bf4.png ../_images/854c6bc62b250821828e20134b3a615b3d954624ff471c0ace0b104bacd26b73.png ../_images/6deca73c0757d61c2e0c2a84216b7835927f63fc1809672d0712ef0a1a9f94a4.png ../_images/19a9a6eaab82e733c03b14376885f0a7f11a3bea0caa6a404f609b7bb9b93a5b.png ../_images/32c5ee5ed5bf8998e371bd919a0d54ad4280469df58dca990540cc96fc7a0fb6.png ../_images/c9314f2d060381044ae550273e7b0f34b44a8d8b40d83e6713fe54bb857f36dc.png ../_images/0f7f8cbe8770fd91b5bcee20dd48f8b898138bcaaff7c8d37c6bc67749464294.png ../_images/c7609cfe8eb32e31e8f9b8f621ec70e2a93614de1fe4b3a914f45c484b4718d2.png ../_images/48b22dc77bb28f09f9dd9e629a6cb437c3a54e4b664e90477134ccd226812f49.png
plot_minimum_money(money_histories, 1000, log_values=True)
../_images/dbdf50d1f32c7e204370128f013816f450168d820ed6d546e53718cfbaa6f16d.png