Advertisement
Guest User

Untitled

a guest
Jan 10th, 2018
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.65 KB | None | 0 0
  1. import random
  2. import matplotlib
  3. matplotlib.use("Qt5Agg")
  4. import matplotlib.pyplot as plt
  5.  
  6.  
  7. import time
  8.  
  9. def roll():
  10.     Roll = random.randint(1,10000)
  11.     edge = 4500
  12.  
  13.     if edge < Roll <= 10000:
  14.         return False
  15.     if Roll <= edge:
  16.         return True
  17.  
  18.  
  19. def kellymans(bankroll, kellyMultiple, bet_count, odds):
  20.     value = bankroll
  21.  
  22.     global valTotalD
  23.  
  24.     wX = []
  25.     vY = []
  26.  
  27.     currentBet = 1
  28.     notLose = True
  29.  
  30.     while currentBet <= bet_count and notLose is True:
  31.         bet = kellyMultiple * value
  32.         if roll():
  33.             value += (odds-1)*bet
  34.             wX.append(currentBet)
  35.             vY.append(value)
  36.         else:
  37.             value = value - bet
  38.             wX.append(currentBet)
  39.             vY.append(value)
  40.         if value <= 0:
  41.             notLose = False
  42.         if currentBet == bet_count:
  43.             valTotalD += value
  44.         currentBet += 1
  45.  
  46.     #plt.figure(1)
  47.     #plt.plot(wX, vY)
  48.  
  49.  
  50. funds = 10000
  51. betCount = 100
  52. sampleSize = 1000
  53. secondSampleSize = 1000
  54.  
  55. x = 1
  56. counter = 1
  57.  
  58. upperBound = 1
  59. lowerBound = 0
  60.  
  61. kX = []
  62. kY = []
  63.  
  64. kellyMultipleTemp = 0
  65. avgValDTemp = 0
  66.  
  67.  
  68. for x in range(sampleSize):
  69.     kellystake = random.uniform(lowerBound, upperBound)
  70.     print('kelly multiple for this run is', kellystake, ', run number is ', x)
  71.  
  72.     valTotalD = 0
  73.  
  74.     for y in range(secondSampleSize):
  75.         kellymans(funds, kellystake, betCount, 2.5)
  76.         counter += 1
  77.  
  78.     avgValD = valTotalD/secondSampleSize
  79.     # print('average bankroll is', avgValD)
  80.  
  81.     kX.append(kellystake)
  82.     kY.append(avgValD)
  83.  
  84.  
  85. #plt.show()
  86. plt.figure(2)
  87. plt.plot(kX, kY, 'ro')
  88. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement