←back to thread

Kelly Can't Fail

(win-vector.com)
393 points jmount | 3 comments | | HN request time: 0.728s | source
Show context
pcthrowaway ◴[] No.42467756[source]
Note that you need to be able to infinitely divide your stake for this to work out for you all the time.

For example, if the deck has 26 red cards on top, you'd end up dwindling your initial $1.00 stake to 0.000000134 before riding it back up to 9.08

replies(7): >>42467772 #>>42467915 #>>42468365 #>>42468411 #>>42470747 #>>42471103 #>>42480391 #
boothby ◴[] No.42467915[source]
If you start out with a $1e12 stake, you're able to avoid catastrophic rounding errors even in the worst case. There's probably a life lesson here.
replies(5): >>42468021 #>>42468417 #>>42476001 #>>42481435 #>>42491135 #
cbsks ◴[] No.42468417[source]
My simulation shows that with a 52 card deck, if you round the bet to the nearest $.01 you will need to start with $35,522.08 to win a total of $293,601.28.

If you start with $35,522.07 or less, you will lose it all after 26 incorrect cards.

replies(3): >>42468767 #>>42468808 #>>42477969 #
1. xelxebar ◴[] No.42477969[source]
Are you sure about those numbers? I get that the smallest fraction of original stake we hit is around 1.35E-7:

          ⊢min←⌊⌿ratio←×⍀{1-d×0⍪¯1↓(+⍀d←¯1+2×⍵)÷⌽⍳≢⍵}52↑26⍴1
    1.353223554704754E¯7
In which case we need to start with $73,897.62

          ⌈÷min
    7389762
For a total payout of $671,088.64

          ⌊(⌈÷min)×⊃⌽ratio
    67108864
Thanks for getting me to actually check this!

Note: above code is Dyalog APL.

replies(1): >>42478173 #
2. cbsks ◴[] No.42478173[source]
I cannot decipher the runes you write, but your magic looks to be more powerful than mine so you are probably right. (i.e., my Python script may have errors; it was pretty hacked together)
replies(1): >>42491879 #
3. xelxebar ◴[] No.42491879[source]
For anyone interested, here's a more pedagogical breakdown of the code:

          ⊢cards←52↑26⍴1         ⍝ We encode a red-black sequence in a bitfield
    1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    
          ⊢rem←⌽⍳≢cards          ⍝ Remaining card count after corresponding play
    51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
    
          ⊢sgn←¯1+2×cards        ⍝ Contribution to re-black delta
    1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ¯1 ¯1 ¯1 ¯1 ¯1 ¯1 ¯1 ¯1 ¯1 ¯1 ¯1 ¯1 ¯1 ¯1 ¯1 ¯1 ¯1 ¯1 ¯1 ¯1 ¯1 ¯1 ¯1 ¯1 ¯1 ¯1
    
          ⊢del←+⍀sgn             ⍝ Delta between count of red vs. black cards
    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
    
          ⊢rat←0⍪¯1↓del÷rem      ⍝ Our ratio is r-b delta as fraction of remaining cards after play
    0 0.01960784314 0.04 0.0612244898 0.08333333333 0.1063829787 0.1304347826 0.1555555556 0.1818181818 0.2093023256 0.2380952381 0.2682926829 0.3 0.3333333333 0.3684210526 0.4054054054 0.4444444444 0.4857142857 0.5294117647 0.5757575758 0.625 0.6774193548 0.7333333333 0.7931034483 0.8571428571 0.9259259259 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
    
          ⊢pay←1-sgn×rat         ⍝ Payout ratio: sgn×rat is negative on win and positive on loss
    1 0.9803921569 0.96 0.9387755102 0.9166666667 0.8936170213 0.8695652174 0.8444444444 0.8181818182 0.7906976744 0.7619047619 0.7317073171 0.7 0.6666666667 0.6315789474 0.5945945946 0.5555555556 0.5142857143 0.4705882353 0.4242424242 0.375 0.3225806452 0.2666666667 0.2068965517 0.1428571429 0.07407407407 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
    
          ⊢tot←×⍀pay             ⍝ Total stake is product scan over individual payout ratios
    1 0.9803921569 0.9411764706 0.8835534214 0.8099239696 0.7237618452 0.6293581262 0.5314579733 0.4348292508 0.3438184774 0.2619569352 0.1916758062 0.1341730644 0.08944870957 0.05649392183 0.03359098055 0.01866165586 0.009597423014 0.00451643436 0.001916063062 0.0007185236481 0.000231781822 0.00006180848586 0.00001278796259 0.000001826851799 1.353223555E¯7 2.706447109E¯7 5.412894219E¯7 0.000001082578844 0.000002165157688 0.000004330315375 0.00000866063075 0.0000173212615 0.000034642523 0.000069285046 0.000138570092 0.000277140184 0.000554280368 0.001108560736 0.002217121472 0.004434242944 0.008868485888 0.01773697178 0.03547394355 0.0709478871 0.1418957742 0.2837915484 0.5675830968 1.135166194 2.270332387 4.540664775 9.081329549
    
          ⊢min←⌊⌿rat             ⍝ Minimum stake
    1.353223554704754E¯7
    
          ⊢start←⌈÷min           ⍝ Minimum starting amount is ceil of inverse min stake
    7389762
    
          ⊢fin←⊃⌽tot             ⍝ Final stake is last element of totals
    9.081329549
    
          ⌊fin×start             ⍝ Gross winnings are floor of start times final stake ratio
    67108864