I'm going through a text on elementary probability theory, http://www.dartmouth.edu/~chance/teaching_aids/books_articles/probability_book/amsbook.mac.pdf, as a refresher and using it as an opportunity to teach myself some programming.
I'm trying to write a simulation for a Labouchere betting system in roulette (question 9 page# 13 in the linked pdf).
I think that I am close to the right answer but I can't figure out how to get the list 'bet' to change for each successive round.
Here is what I have so far:
def Labouchere(T):
bet, mon = [4,3,2,1], 0
for t in range(0,T):
ball = random.uniform(0.0,1.0)
if ball < (18/float(38)):
mon += (bet[0] + bet[-1])
np.delete(bet, 0, 0)
np.delete(bet, -1, 0)
elif ball >= (18/float(38)):
mon -= (bet[0] + bet[-1])
np.insert(bet, 0, (bet[0]+bet[-1]))
else:
break
return mon
Any help is much appreciated. I am also trying to learn from Steven F. Lott's book 'Building Skills in Object-Oriented Design' but it seems to be above my level of understanding so far. A recommendation for material that would prep me for using that guide would also be invaluable.
Thanks in advance.