Advertisement
azer67

TWWHD auction odds

Oct 25th, 2018 (edited)
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.88 KB | None | 0 0
  1. 0 JPs odds = 20.0 % ( 1/5 )
  2. better than in 100.0 % of cases
  3.  
  4. 1 JPs odds = 25.666666666666664 % ( 77/300 )
  5. better than in 80.0 % of cases
  6.  
  7. 2 JPs odds = 21.105555555555554 % ( 3799/18000 )
  8. better than in 54.333333333333336 % of cases
  9.  
  10. 3 JPs odds = 14.232685185185185 % ( 153713/1080000 )
  11. better than in 33.22777777777778 % of cases
  12.  
  13. 4 JPs odds = 8.605603395061728 % ( 5576431/64800000 )
  14. better than in 18.995092592592595 % of cases
  15.  
  16. 5 JPs odds = 4.871278215020576 % ( 189395297/3888000000 )
  17. better than in 10.389489197530864 % of cases
  18.  
  19. 6 JPs odds = 2.6444253425068585 % ( 6168915439/233280000000 )
  20. better than in 5.518210982510288 % of cases
  21.  
  22. 7 JPs odds = 1.3968875985439528 % ( 195519563393/13996800000000 )
  23. better than in 2.873785640003429 % of cases
  24.  
  25. 8 JPs odds = 0.724656520608401 % ( 6085723432591/839808000000000 )
  26. better than in 1.4768980414594763 % of cases
  27.  
  28. 9 JPs odds = 0.37140634380957116 % ( 187146011269217/50388480000000000 )
  29. better than in 0.7522415208510755 % of cases
  30.  
  31. 10 JPs odds = 0.18881637517154976 % ( 5708502086402479/3023308800000000000 )
  32. better than in 0.3808351770415043 % of cases
  33.  
  34. 11 JPs odds = 0.09546812546593976 % ( 173177774304407873/181398528000000000000 )
  35. better than in 0.19201880186995457 % of cases
  36.  
  37. 12 JPs odds = 0.04809300814416905 % ( 5234400530666566351/10883911680000000000000 )
  38. better than in 0.09655067640401481 % of cases
  39.  
  40. 13 JPs odds = 0.02416757712260363 % ( 157822664953203874337/653034700800000000000000 )
  41. better than in 0.04845766825984575 % of cases
  42.  
  43. 14 JPs odds = 0.01212450566663803 % ( 4750633758216522663919/39182082048000000000000000 )
  44. better than in 0.024290091137242124 % of cases
  45.  
  46. 15 JPs odds = 0.006075915712581882 % ( 142840216780269414545153/2350924922880000000000000000 )
  47. better than in 0.012165585470604093 % of cases
  48.  
  49. 16 JPs odds = 0.0030425349081549284 % ( 4291662686588300113213711/141055495372800000000000000000 )
  50. better than in 0.00608966975802221 % of cases
  51.  
  52. EXPECTED NUMBER OF JPs: 2.0827848259840214
  53.  
  54. I believe the actual expected number of joy pendants should be 25/12, as this can be seen as several negative binomial distributions which we can add up the expected number of JPs from.
  55.  
  56.  
  57. CODED WITH PYTHON:
  58.  
  59. from fractions import *
  60.  
  61. def auction():
  62. L=[]
  63. M=[]
  64. N=[]
  65. for i in range(17):
  66. L.append(auctionodd(i))
  67. M.append(morejpsthan(i))
  68. print(i,'JPs odds =',L[i][1]*100, '% (',L[i][0], ')' )
  69. print('better than in', M[i].numerator/M[i].denominator*100,'%','of cases')
  70. print()
  71. print('EXPECTED NUMBER OF JPs:',expectedwithlist(L))
  72.  
  73. def auctionodd(n):
  74. rep=auction_aux(n,[1]*(n+4))
  75. return rep, rep.numerator/rep.denominator
  76. #liste de taille n+4 car n JPs et 4 items
  77. #dans la liste, 1 pour item, 0 pour JP
  78.  
  79. def auction_aux(n,L):
  80. odd=0
  81. longueur=len(L)
  82. if n==0:
  83. return proba(L)
  84. else:
  85. if 0 not in L:
  86. latestjp=0
  87. else:
  88. for i in range(0, longueur-1):
  89. if L[i]==0:
  90. latestjp=i
  91. for i in range(latestjp,longueur-1):
  92. #starting at latestjp in order to have every case only show once
  93. if L[i]==1:
  94. L[i]=0
  95. odd+=auction_aux(n-1,L)
  96. #programme recursif
  97. L[i]=1
  98. return odd
  99.  
  100. def proba(L):
  101. items=4
  102. odds=Fraction(1,1)
  103. longueur=len(L)
  104. for j in range(0,longueur):
  105. if L[j]==0:
  106. odds*=Fraction(1,items+1)
  107. else:
  108. odds*=Fraction(items,items+1)
  109. items-=1
  110. return odds
  111.  
  112. def expectedwithlist(L):
  113. value=Fraction(0,1)
  114. n=len(L)
  115. for i in range(0,n):
  116. value+=i*L[i][0]
  117. return value.numerator/value.denominator
  118.  
  119. def expected(n):
  120. value=0
  121. for i in range(0,n+1):
  122. value+=i*auctionodd(i)[1]
  123. return value
  124.  
  125. def morejpsthan(n):
  126. return 1-sum(auctionodd(i)[0] for i in range(0,n))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement