Roulette simulation: 10'000 players each betting 5'000 times (74% chance of having a negative return ) [OC]
Submitted by nautilus_red t3_y1aw8v in dataisbeautiful
What do they bet? On a number ? On a color?
Thanks for pointing out, single numbers only.
Did you run it with a
payout of 35 or 36?
Normal table or double zero?
I used 35x payout and a normal table.
Can you please post the code?
I am not sure if there is any good way to do that other than paste it in here but here you go.
​
FYI: I first had some serious ugly for loops to simulate it which was extremely slow so I coded it more efficiently as you can find below (probably it's a bit less intuitive though, I don't know).
######### Simulation #########
import random
import numpy as np
k = 50000000
returns = [-5 for i in range(0,36)]+[170]
return_arr = np.array(random.choices(returns, k = k)).reshape(int(k/5000),5000)
return_arr_sum = np.sum(return_arr, axis=1)
return_arr_cumsum = np.cumsum(return_arr,axis=1)
return_arr_aux = np.ones((10000,5000), dtype=int)*10000
return_path = return_arr_cumsum + return_arr_aux
​
######### Chart #########
​
import matplotlib.pyplot as plt
from matplotlib.pyplot import figure
figure(figsize=(15, 7), dpi=100)
# plot 1
plt.subplot(1, 2, 1)
plt.plot(return_path.T, linewidth = 0.2)
plt.title("Roulette Simulation of " + str(5000) + " Bets \n Start = 10'000 \$, 5 $ per Bet \n ("+str(int(k/5000))+" Player Paths Simulated)")
plt.xlabel("# Bets", fontsize=12)
plt.ylabel("Total Money Left", fontsize=12)
# plot 2
plt.subplot(1, 2, 2)
pos = [i for i in [return_path[i][-1]-10000 for i in range(0,len(return_path))] if i>=0]
neg = [i for i in [return_path[i][-1]-10000 for i in range(0,len(return_path))] if i<0]
plt.hist(pos, bins = 100, orientation="horizontal", color="green")
plt.hist( neg, bins = 100, orientation="horizontal", color= "red")
plt.title("Distribution of Player Returns After " + str(5000)+ " Bets")
plt.xlabel("# People", fontsize=12)
plt.ylabel("\n Player Profit/Loss", fontsize=12)
plt.show()
You can embed blocks of code like this
'''This code will print a lost containing numbers 1 through 10'''
import numpy as np
np_array = np.array([])
for i in range(1, 11) :
np_array = np.append(np_array, i)
print(np_array)
​
by using the option found here
[removed]
The better way to do this would be to either create a GitHub repo, or a GitHub gist. Repos are harder to work with but have lots of features for collaboration and bug tracking, gists are easy to use and only have a few features, it's meant to share code snippets and that's it.
I never really used GitHub but it seems that it would be a good investment to look at it if I want to do some more mini projects. Thanks!
Definitely! It's what most software folks use as a portfolio so I'd highly recommend digging into it at some point :)
It would effect the rising and falling of each player's line but the average at the end should be more or less the same.
Agreed! Please don’t hate me for pointing this out, but I think I you could say it would affect it or you can also say that it would have an effect on it.
I don’t hate you, you’re 100% right.
Viewing a single comment thread. View all comments