Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- import matplotlib
- matplotlib.use("Qt5Agg")
- import matplotlib.pyplot as plt
- import time
- def roll():
- Roll = random.randint(1,10000)
- edge = 4500
- if edge < Roll <= 10000:
- return False
- if Roll <= edge:
- return True
- def kellymans(bankroll, kellyMultiple, bet_count, odds):
- value = bankroll
- global valTotalD
- wX = []
- vY = []
- currentBet = 1
- notLose = True
- while currentBet <= bet_count and notLose is True:
- bet = kellyMultiple * value
- if roll():
- value += (odds-1)*bet
- wX.append(currentBet)
- vY.append(value)
- else:
- value = value - bet
- wX.append(currentBet)
- vY.append(value)
- if value <= 0:
- notLose = False
- if currentBet == bet_count:
- valTotalD += value
- currentBet += 1
- #plt.figure(1)
- #plt.plot(wX, vY)
- funds = 10000
- betCount = 100
- sampleSize = 1000
- secondSampleSize = 1000
- x = 1
- counter = 1
- upperBound = 1
- lowerBound = 0
- kX = []
- kY = []
- kellyMultipleTemp = 0
- avgValDTemp = 0
- for x in range(sampleSize):
- kellystake = random.uniform(lowerBound, upperBound)
- print('kelly multiple for this run is', kellystake, ', run number is ', x)
- valTotalD = 0
- for y in range(secondSampleSize):
- kellymans(funds, kellystake, betCount, 2.5)
- counter += 1
- avgValD = valTotalD/secondSampleSize
- # print('average bankroll is', avgValD)
- kX.append(kellystake)
- kY.append(avgValD)
- #plt.show()
- plt.figure(2)
- plt.plot(kX, kY, 'ro')
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement