pcthrowaway 4 days ago

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

  • boothby 4 days ago

    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.

    • cbsks 4 days ago

      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.

      • boothby 4 days ago

        Nearest rounding does seem like a mistake here. Rounding down is quite safe: rather than lose it all, you end up with at least 2^26 pennies.

      • xelxebar 3 days ago

        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.

        • cbsks 3 days ago

          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)

          • xelxebar a day ago

            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
    • TeMPOraL 3 days ago

      When Poland first introduced the capital gains tax in 2002, banks were quick to notice the tax law still generally required tax amounts to be rounded to nearest full złoty when accrued, so they started offering financial products with daily capitalization, which were effectively exempt from the new capital gains tax, as for most customers, the daily gain would be low enough that the tax on it always rounded down to zero. This only got corrected 10 years later.

      I find it fascinating that we could have a whole class of financial products hinging on something seemingly so trivial as a rounding strategy.

    • fragmede 4 days ago

      Is the lesson: choose to be born to wealthy parents?

      • renewiltord 4 days ago

        A popular view is that having wealthy parents gives one a great advantage. Another popular view is that working extraordinarily hard for money is a waste of one’s life even if one gets the money. But the two are only consistent if one believes that one’s own life is the optimization target. If I live a life of misery so that my children live a life of prosperity that would strike me as a phenomenal result.

        So another reading is “choose to give your children wealthy parents”.

      • mannykannot 4 days ago

        It would really help if your parents know someone who can and will take the other side in this game.

      • darkerside 4 days ago

        Or is it to choose appropriate betting amounts based on your capacity for risk

        • laidoffamazon 4 days ago

          I guess it then does follow that having rich parents does expand your capacity for risk!

        • Onavo 4 days ago

          IEEE-754 isn't precise enough for my capacity :( I too need rich parents.

        • User23 4 days ago

          The lesson I'm taking away is "learn math and how to use it."

          • paulluuk 4 days ago

            Applying math to a more practical betting situation, like poker, is a lot harder. You'd have to be able to calculate your exact odds of winning given only a small amount of information, without a calculator and without it taking so long that the other players notice, and then also factor in the odds that the other players are bluffing and the advantages that you might have from (not) bluffing.

          • barrenko 4 days ago

            Learn math and discover poignantly all the situations where it is effectively useless.

        • Etheryte 4 days ago

          Or is it to choose appropriate betting amounts based on your parents?

      • Rastonbury 3 days ago

        Practically if you live life fearing a 26 red cards event something like e-15, you'd never leave the house and leave your money under your bed

      • croes 4 days ago

        It’s easier to make money if you already habe money

  • jmount 4 days ago

    Very good point. I did some experiments and the system is very sensitive to any sort of quantization or rounding of bets. You get the expected value about the right place, but the variance goes up quickly. So in addition to your important case, things are a bit dicey in general.

  • kamaal 4 days ago

    >>Note that you need to be able to infinitely divide your stake for this to work out for you all the time.

    This is what most people discover, you need to play like every toss of the coin(i.e tosses over a very long periods of time). In series, like the whole strategy for it to work as is. You can't miss a toss. If you do you basically are missing out on either series of profitable tosses, or that one toss where you make a good return. If you draw the price vs time chart, like a renko chart you pretty much see a how any chart for any instrument would look.

    Here is the catch. In the real world stock/crypto/forex trading scenario that means you basically have to take nearly trade. Other wise the strategy doesn't work as good.

    The deal about tossing coins to conduct this experiment is you don't change the coin during the experiment. You don't skip tosses, you don't change anything at all. While you are trading all this means- You can't change the stock that you are trading(Else you would be missing those phases where the instruments perform well, and will likely keep landing into situations with other instruments where its performing bad), you can't miss trades, and of course you have to keep at these for very long periods of time to work.

    Needless to say this is not for insanely consistent. Doing this day after day can also be draining on your mental and physical health, where there is money there is stress. You can't do this for long basically.

    • teo_zero 4 days ago

      While I don't agree on nearly anything you stated, I enjoyed your prose: I suppose you left out words here and there as a metaphorical proof of your claim that you can't miss a single toss, didn't you?

      • kamaal 4 days ago

        >>I suppose you left out words here and there as a metaphorical proof of your claim that you can't miss a single toss, didn't you?

        You must always practice in real world conditions. Notice in the experiments conducted in programs, you are taking series of tosses as they come, even if they are in thousands in numbers, one after the other, without missing a single one. Unless you can repeat this in a live scenario. This is not a very useful strategy.

        Kelly criterion is for people who are planning to take large number of trades over a long period of time, hence the idea is to ensure failures are not fatal(this is what ensures you can play for long). As it turns out if you play for really long, even with a small edge, small wins/profits tend to add to something big.

        If you remove all the math behind it, its just this. If you have a small edge to win in a game of bets, find how much you can bet such that you don't lose your capital. If you play this game for long, like really really long, you are likely to make big wins.

        • teo_zero 4 days ago

          You are conflating 2 concepts: a) that the reality converges to what the theory predicts only after a great number of samples; b) that if you skip some events the results will vary.

          Now, b) is false. You can change the code to extract 3 random numbers each time, discard the first 2 and only consider the third one, the results won't change.

          Instead a) is generally true. In this case, the Kelly strategy is the best strategy to play a great number of repeated games. You could play some games with another strategy and win more money, but you'll find that you can't beat Kelly in the long term, ideally when the repetitions approach infinity.

          • kamaal 4 days ago

            >>Now, b) is false. You can change the code to extract 3 random numbers each time, discard the first 2 and only consider the third one, the results won't change.

            Might be in theory. In practice, this is rarely true.

            Take for example in trading. What happens(is about to happen), depends on what just happened. A stock could over bought/over sold, range bound, moving in a specific direction etc. This decides whats about to happen next. Reality is rarely ever random.

            Im sure if you study a coin toss for example, you can find similar patterns, for eg- if you have tired thumb, Im pretty sure it effects the height of the toss, effecting results.

            >>Instead a) is generally true. In this case, the Kelly strategy is the best strategy to play a great number of repeated games.

            Indeed. But do make it a point to repeat exact sequences of events you practiced.

            • ziofill 2 days ago

              I think the word you need to use in this conversation is iid.

    • auc 4 days ago

      If you assume coin tosses are independent, it shouldn’t matter if you miss coin tosses.

      • kamaal 4 days ago

        Coin tosses are not independent. Unless the premise is coins toss themselves.

        A person tosses a coin, so tosses are are connected to each other.

        Ask yourself this question- Would your thumb hurt if you toss a coin 5000 times? If so, would that change the results?

        • PaulHoule 4 days ago

          Naturally tossed coins tend to land on the same side they started with 0.51 of the time, see

          https://www.stat.berkeley.edu/~aldous/157/Papers/diaconis_co...

          • aidenn0 4 days ago

            Linked paper does not state that; it states that tossed coins tend to be caught on the same side they stared with slightly more than half the time. The results explicitly exclude any bouncing (which will happen if a coin lands on a hard surface).

            The paper does discuss coins allowed to land on a hard surface; it is clear that this will affect the randomness, but not clear if it increases or decreases randomness, and suggests further research is needed.

          • kamaal 3 days ago

            Nice try, but-

            The machine they use to toss the coin has a spring, and Im sure the spring tension varies through time effecting results.

  • tgma 4 days ago

    Yup, the dual would be saying Martingale can't fail with infinite money.

    • aidenn0 4 days ago

      It's not because there is a finite amount of money at which this can't fail, which is never the case for martingale. Martingale is actually likely to bankrupt you against a casino that is much more well staked than you even if you have a small advantage.

  • nyeah 4 days ago

    It's a good point. I think it affects the realism of the model. When the stake is very low, finding a penny on the street gives an astronomical improvement in the end results. At the high end, it's possible the counterparty might run out of money.

  • ab_goat 4 days ago

    Finally a real world use case for bitcoin!

    • amanda99 4 days ago

      Bitcoin isn't infinitely divisible, you can't do smaller than one satoshi.

lordnacho 4 days ago

Interesting side note on Kelly:

In probability theory, Proebsting's paradox is an argument that appears to show that the Kelly criterion can lead to ruin. Although it can be resolved mathematically, it raises some interesting issues about the practical application of Kelly, especially in investing. It was named and first discussed by Edward O. Thorp in 2008.[1] The paradox was named for Todd Proebsting, its creator.

https://en.wikipedia.org/wiki/Proebsting%27s_paradox

  • dominicrose 4 days ago

    Quoting the same page: One easy way to dismiss the paradox is to note that Kelly assumes that probabilities do not change.

    That's good to know. Kelly is good if you know the probabilities AND they don't change.

    If you don't know or if they can change, I expect the right approach has to be more complex than the Kelly one.

    • cubefox 4 days ago

      In particular, then the right approach has to be more risk averse than Kelly would recommend. In reality, most probabilities can only be estimated, while the objective probabilities (e.g. the actual long run success rate) may well be different and lead to ruin. That's also what makes the title "Kelly can't fail" more wrong than right in my opinion.

      • LegionMammal978 4 days ago

        For the issue in Proebsting's paradox, one simple approach I've found successful is to gradually accumulate your full bet as the betting lines progress to their ultimate positions. This works even in illiquid markets where your bets affect the lines, since it gives the other participants less room to suddenly react to what you're doing. (Though you always have the slight worry of a huge last-second bet that you can't react to, eBay-auction style.)

        As for the actual probability being different from the expected probability, that's not too difficult to account for. Just set up a distribution (more or less generous depending on your risk tolerance) for where you believe the actual probability may lie, and work out the integrals as necessary, recalling that you want to maximize expected log-value. It's not the trivial Kelly formula, but it's exactly the same principle in the end.

        • cubefox 4 days ago

          I think the problem with estimating a distribution is the same, it might simply not match reality (actual unknown success rates, actual unknown variance of your estimation of success rates being correct). In particular, if you are too optimistic relative to reality, Kelly betting will lead to ruin with high objective probability.

          • kqr 3 days ago

            There are people who can verifiably estimate unknown probabilities with accuracy finer than 5 percentage points. These are called superforecasters.

            Almost all people can achieve at least 20 point accuracy with a few hours of training. Unknown probabilities are not so problematic as people make them out to be.

            Probabilities are literally measures of uncertainty. It's okay for them to be uncertain. They always are.

            • cubefox 3 days ago

              Kelly betting is a rare case where the difference between subjective and objective betting is actually a big deal, because any difference in those probabilities can make a large difference in the amount of money the Kelly formula says you should bet. I don't know the exact source, but there was a YouTube video on Kelly showing the impact of miscalibrated probabilities using simulations.

            • LegionMammal978 3 days ago

              Yeah, that's why I mentioned creating a very generous distribution for the probability if you don't want the risk of being wrong. You can set up the maximization step just the same, and the wider the distribution, the more conservative it will tell you to be, until ultimately it says not to take the bet at all, since you have no edge. If you're really risk-adverse, you can go with a full min-max approach, where you bet as if the actual probability is unfavorable as possible. You just end up making suboptimal choices compared to someone who (accurately) puts a narrower distribution on the probability.

              Also, your estimate of the true probability doesn't have to be that exact, if your edge is big enough to begin with. Once I made great profits (betting with fake internet points) just by naively taking the sample proportion from a small sample. In fact, the event turned out to be more 'streaky' than a weighted coin flip, but it didn't matter, since everyone else there was betting on vibes.

              In any case, it's not like there's just the trivial Kelly formula, and woe to you if its toy model doesn't apply precisely to your situation. It's a general principle that can be adapted to all sorts of scenarios.

      • lupire 4 days ago

        The title is gentle clickbait applies to one specific game with 0 variance, not to all uses of Kelly.

    • csours 4 days ago

      Unfortunately, in the real world, playing the game changes the game.

      For instance, casinos have different payout schedules for Blackjack based on minimum bet size and number of decks in the shoe. Payouts for single deck Blackjack are very small in comparison to multi-deck games, as well as requiring larger minimums (and they shuffle the deck after only a few hands).

ilya_m 4 days ago

Beautiful, thanks for sharing it!

I think the portfolio argument is an unnecessary detour though. There's a two-line proof by induction.

1. The payoff in the base case of (0,1) or (1,0) is 2.

2. If we are at (r,b), r >=b , have $X, and stake (r-b)/(r+b) on red, the payoff if we draw red and win is X * (1+(r-b)/(r+b)) * 2^(r+b-1) / (r+b-1 choose r-1) = X * 2^(r+b) * r / ((r+b) * (r+b-1 choose r-1)) = X * 2^(r+b) / (r+b choose r).

Similarly, if we draw black and lose, the payoff is X * (1-(r-b)/(r+b)) * 2^(r+b-1) / (r+b-1 choose r) = X * 2^(r+b) * b / ((r+b) * (r+b-1 choose r)) = X * 2^(r+b) / (r+b choose r). QED

  • lupire 4 days ago

    Why isn't your inductive proof an unnecessary detour?

fancy_pantser 4 days ago

A very similar card game played by deciding when to stop flipping cards from a deck where red is $1 and black is −$1 as described in Timothy Falcon’s quantitative-finance interview book (problem #14). Gwern describes it and also writes code to prove out an optimal stopping strategy: https://gwern.net/problem-14

  • snthpy 4 days ago

    Nice!

    Only quibble i have is that black should be +$1 and red -$1 to follow standard finance conventions, i.e. be in the "black" or "red".

  • jmount 4 days ago

    That is a nice game and writeup.

PaulHoule 4 days ago

When I was a teen I discovered that I could always guess more than half the cards right using card counting to determine what color is more common in the deck. I programmed my

https://en.wikipedia.org/wiki/TRS-80_Model_100

to simulate it and it never failed. Recently I thought about it again and wrote a Python script that tried it 30 million times and... it never failed.

I've been thinking about what to do with it and came up with the options of (i) a prop bet and (ii) a magic trick, neither of which seemed that promising.

As a prop bet I can offer $1000 to somebody's $10 which is not the route to great prop bet profits, also I worry that if I make a mistake or get cheated somehow I could be out a lot of money. (Now that I think of it maybe it is better if I re-organize it as a parlay bet)

As a magic trick it is just too slow paced. I developed a patter to the effect that "Parapsychologists were never able to reliably demonstrate precognition with their fancy Zener cards, but I just developed a protocol where you can prove it every time!" but came to the conclusion that it was not entertaining enough. It takes a while to go through a deck which doesn't seem like a miracle, you will have to do it 7 times in a row to exclude the null hypothesis at p=0.01. Maybe somebody with more showmanship could do it but I gave up.

  • jdhwosnhw 4 days ago

    That reminds me of my favorite algorithm, which can find the majority element in a list with any number of distinct entries while using O(N) time and O(1) space (provided a majority element exists). I sometimes pose deriving this algorithm as a puzzle for people, no one has ever solved it (nor could I).

    https://en.m.wikipedia.org/wiki/Boyer%E2%80%93Moore_majority...

    • lupire 4 days ago

      What's great about that is that the assumption (or O(n) check) that the majority exists is incredibly powerful, enabling the algorithm, which is nearly the dumbest possible algorithm, to work.

      The one flaw in the magic is that "2nd pass to verify" is a significant cost, transforming the algorithm from online streaming O(1) space to O(n) collection-storage space.

      • jdhwosnhw 3 days ago

        Ah shoot I never thought of that. I wonder if there’s a sneaky way around it? You’re right, that definitely impacts the utility of the algorithm.

    • barapa 4 days ago

      That is really cool

  • thaumasiotes 3 days ago

    > Recently I thought about it again and wrote a Python script that tried it 30 million times and... it never failed.

    There are enough possible card sequences that you might be concerned about your source of pseudorandomness failing to exhaust the space. Simulations can give you very misleading results when that happens.

    Even if you do have enough entropy, 30 million trials is definitely not enough.

JohnMakin 4 days ago

Kelly criterion is one of my favorite game theory concepts that is used heavily in bankroll management of professional gamblers, particularly poker players. It is a good way to help someone understand how you can manage your finances and stakes in a way that allows you to climb steadily forward without risking too much or any ruin, but is frequently misapplied in that space. The problem is kelly deals with binary results, and often situations in which this is applied where the results are not binary (a criteria for applying this) you can see skewed results that look almost right but not quite so, depending on how you view the math

  • amluto 4 days ago

    > particularly poker players

    The Kelly criterion seems excellent for many forms of gambling, but poker seems like it could be an exception: in poker, you’re playing against other players, so the utility of a given distribution of chips seems like it ought to be more complicated than just the number of chips you have.

    (I’m not a poker player.)

    • tempestn 4 days ago

      It's used for bankroll management (basically deciding what stakes to play) rather than for sizing bets within a particular game.

    • fernandopj 4 days ago

      Chris "Jesus" Ferguson "proved" an application of this theory back in ~2009 [1]. He was a the time promoting Full Tilt and commited to turn $1 dollar bankroll to $10000 by applying a basic strategy of never using more than a low % of his bankroll into one tournament or cash game session.

      So, if one's skill would turn your session probability to +EV, by limiting your losses and using the fact that in poker the strongest hands or better tourney positions would give you a huge ROI, it would be just a matter of time and discipline to get to a good bankroll.

      Just remember that for the better part of this challenge he was averaging US$ 0.14/hour, and it took more than 9 months.

      [1] https://www.thehendonmob.com/poker_tips/starting_from_zero_b...

      • kelnos 4 days ago

        > Just remember that for the better part of this challenge he was averaging US$ 0.14/hour, and it took more than 9 months.

        But consider the rate of return! He turned $1 into $10,000 in 9 months. Could he then turn that $10k into $100M in another 9 months?

        Or if he'd started with $100 instead of $1, could he have turned that into $1M in 9 months? That would still be incredibly impressive.

        Certainly the game changes as the bets and buy-ins get higher, but even if he couldn't swing the same rate of return with a higher starting point and larger bets (though still only betting that same certain low percent of his bankroll), presumably he could do things like turning $5k into $1M. Even $100k into $1M would be fantastic.

        • lupire 4 days ago

          I think the challenge is that the larger you bet, the harder it is to find people who are bad at basic strategy poker but willing to bet against you for a long series of bets.

  • kqr 3 days ago

    > The problem is kelly deals with binary results,

    Incorrect. https://entropicthoughts.com/the-misunderstood-kelly-criteri...

    The Kelly criterion generalises just fine to continuous, simultaneous, complicated allocations.

    All it takes is a list of actions which we are choosing from (and these can be compound actions with continuous outcomes) and the joint probability distribution of wealth outcomes after each action.

  • bloodyplonker22 4 days ago

    You are right that Kelly criterion deals with binary results. This won't work for poker. In poker, we use expected value because wins and losses are not binary because of the amount you win or lose. Once you figure out your approximate EV, you use a variance calculator in addition to that (example: https://www.primedope.com/poker-variance-calculator/) to see how likely and how much it is you will be winning over a certain number of hands in the long run.

  • peter_retief 4 days ago

    Could this work with roulette betting on color? Seems like you could spend a lot of time not winning or losing

    • plorkyeran 4 days ago

      Roulette results are uncorrelated and you have the exact same chance of winning each time, so the Kelly criterion isn’t applicable. Betting on a color has a negative edge and you don’t have the option of taking the house’s side, so it just tells you the obvious thing that you should bet zero.

      • dmurray 4 days ago

        > exact same chance of winning each time, so the Kelly criterion isn’t applicable.

        Actually, the main assumption that leads to the Kelly criterion is that you will have future opportunities to bet with the same edge, not constrained by the amount.

        For example, if you knew this was your last profitable betting opportunity, to maximise your expected value you should bet your entire stake.

        I'm slightly surprised it leads to such a nice result for this game - I don't see a claim that this is the optimal strategy for maximizing EV zero variance is great, but having more money is also great.

        Of course you are right about roulette and, if you are playing standard casino roulette against the house, the optimal strategy is not to play. But that's not because bets are uncorrelated, it's because they are all negative value.

        • kqr 3 days ago

          > Actually, the main assumption that leads to the Kelly criterion is that you will have future opportunities to bet with the same edge, not constrained by the amount.

          Not the same edge -- any edge! And this condition of new betting opportunities arriving every now and then is a fairly accurate description of life, even if you walk out of the casino.

      • Tepix 4 days ago

        What makes 0 better than the other numbers?

        • Vecr 4 days ago

          Can't bet negative in that kind of game. If a game is expected to lose you money, don't play.

        • lupire 4 days ago

          $0, not 0 on the wheel.

barbegal 4 days ago

It would have been a better demo if reduced to more manageable numbers e.g. a deck of 2 black and 2 red cards.

Turn 1 r = b so no bet

Turn 2 bet 1/3 on whichever card wasn't revealed in turn 1.

Turn 3 either you were wrong on turn 2 and you now have 2/3 of your stake but you know the colour of the next two cards so you can double your stake each time to end up with 4/3 after turn 3 or you were right and you have 4/3 of your stake but have one of each red or black left so you don't bet this turn.

Turn 4 you know the colour of the final card so you double your money to 8/3 of your original stake.

And then the exercise to the reader is to prove optimality (which is fairly straightforward but I don't believe there is a short proof)

  • libraryofbabel 4 days ago

    Yes. Although four cards has only one nontrivial branch, on turn 3. So, start out with the four cards example, and then show tree diagrams for the 5 and 6 cards cases (still manageable numbers) to build intuition for induction to the general case.

  • stevage 4 days ago

    Agreed, I could follow the general argument but not enough to be convinced about why the result is exactly the same regardless of the order of cards.

andrewprock 4 days ago

In practice, there are a number of factors which make using Kelly more difficult than in toy examples.

What is your bankroll? Cash on hand? Total net worth? Liquid net work? Future earned income?

Depending on the size of your bankroll, a number of factors come in to play. For example, if your bankroll is $100 and you lose it all it's typically not a big deal. If you have a $1 million bankroll, then you are likely more adverse to risking it.

What is the expected value? Is it known? Is it stationary? Is the game honest?

Depending on the statistical profile of your expected value, you are going to have to make significant adjustments to how you approach bet sizing. In domains where you can only estimate your EV, and which are rife with cheats (e.g. poker), you need to size your wagers under significant uncertainty.

What bet sizes are available?

In practice, you won't have a continuous range of bet sizes you can make. You will typically have discrete bet sizes within a fixed range, say $5-$500 in increments of $5 or $25. If your bankroll falls to low you will be shut out of the game. If your bankroll gets too high, you will no longer be able to maximize your returns.

At the end of the day, professional gamblers are often wagering at half-kelly, or even at quarter-kelly, due in large part to all these complexities and others.

  • zahlman 4 days ago

    > In practice, you won't have a continuous range of bet sizes you can make.

    You may also be required to pay for the privilege of placing a bet (spread and commissions in trading; the rake at a casino table).

hawkjo 5 days ago

Very cool to see no variance in the outcome. But that also makes it feel like there should be a strategy with better expected return due to the unique problem structure. Do we know if the Kelly strategy is optimal here?

  • travisjungroth 4 days ago

    I have a feeling it’s the highest EV. I tried a strategy of flipping all the cards until there’s only one color left and then betting it all every time. Ran a million trials and got 9.08.

    I was thinking these are very different strategies, but they’re not exactly. The Kelly strategy does the same thing when there’s only one color left. The difference is this strategy does nothing before that point.

    Still, they feel like limit cases. Betting it all with only one color left is the only right move, so it’s what you do before that. Nothing and Kelly seem like the only good strategies.

    • foota 4 days ago

      Ah, but these aren't the same. The Kelly strategy has zero variance, whereas this strategy likely has very high variance.

      It would be interesting to do the math and show why they're equal. It seems like you should be able to make the same sort of portfolio probability argument.

      • foota 4 days ago

        To start, your minimum return is 2x, and depending on how many cards of a single color are left at the end, you get a return of 2^N. You could take the summation of those N card returns, times the probability of each, and that must come out to 9.08 on average.

        I guess the number of possible arrangements of cards with N of one color remaining is... The number of permutations of N times 2 times the number of permutations of 52 minus N times 26 choose N?

        Ah, yes this works, you can see it here: https://www.wolframalpha.com/input?i=%28summation+of+N%21+*+....

        That is: (summation of N! * (52 - N)!* (26 choose N) * 2^N/52! from N=0 to 26 (for some reason the * 2 for different suits was over counting, so I removed it. Not sure why? Also it seems like it should be from 1 to 26, but that also doesn't give the right answer, so something is whack)

      • travisjungroth 4 days ago

        Of course they're not the same. They have the same EV and the strategies do the same thing in a condition that always happens: there's only one color left. The variance is wildly different.

  • rahimnathwani 4 days ago

      Do we know if the Kelly strategy is optimal here?
    
    What do you mean by optimal? Do you mean you're willing to risk going bankrupt, if it means a higher expected value?
    • scotty79 4 days ago

      Surely there's some space between risking to go bankrupt and risking of getting less than 9.08 return guaranteed by Kelly strategy.

      If you are willing to take some risk in exchange for possibility of higher payout just bet a bit more then Kelly recommends. That's your "optimal" strategy for the amount of risk you are willing to take. I imagine it's expected return is the same as Kelly and calculating it's variance is left as the exercise for the reader.

      • rahimnathwani 4 days ago

          I imagine it's expected return is the same as Kelly
        
        Given two options with the same expected return, most people would prefer the lower variance.

        Accepting higher variance with no increase in expected return has a name: gambling.

  • jmount 5 days ago

    The book claims it is optimal for a set of strategies they called "sensible." I didn't think the argument flowed as well as the zero variance part of the proof, so I didn't work it in. I think the source also hinted at a game-theory proof as they called the sub-strategies in the portfolio "pure strategies."

  • OscarCunningham 4 days ago

    In this game, all strategies have the same expected value, so long as they follow the rule 'if the remaining deck is all the same colour, then you should bet everything you have on that colour'.

  • lupire 4 days ago

    The Kelly criterion is the strategy with better return due to the uniquely problem structure.

  • barbegal 4 days ago

    It is optimal for expected returns yes.

amluto 4 days ago

> The problem and solution appear to come from Thomas Cover.

I don’t recall this specific example, but I learned about the Kelly criterion in a class that Thomas Cover taught. He was one of my favorite teachers, and any discussion with him was guaranteed to be interesting and worthwhile. RIP.

  • kqr 3 days ago

    He's contributed a lot of interesting papers in this area too -- some of them make up a significant chunk of the book on the Kelly criterion!

raydiak 4 days ago

As a guy named Kelly, I appreciate the vote of confidence!

  • pvg 4 days ago

    I think you're underselling it a bit, it's a decree of confidence rather than a mere vote.

Vecr 5 days ago

Checks out with multiple RNG seeds.

It shouldn't be a problem because the RNG is advanced each run. Might save someone a check though.

  • jmount 5 days ago

    I love that. Gaming the seed is always a possibility in demos.

im3w1l 4 days ago

This article uses stake to mean bankroll, but usually it denotes bet size.

lupire 4 days ago

Intuition for the bet size:

When the deck has d cards left, it is sensible to make d bets of 1/d your stack, where each bet is that one specific card is next. If there are r reds and b=r+e blues, r of these bets simply cancel out r other bets, leaving e (times 1/d) remaining to be a nontrivial bet.

gcanyon 3 days ago

I guess it's kind of intuitive that if you are playing an exhaustive game (all 52 cards) that the optimal solution would not only be optimal but deterministically so. But I wonder if that idea just feels good and isn't true. Is it false? Anyone have a counter-example?

malisper 4 days ago

I need to do some Math, but I wonder if there's a better strategy than Kelly betting. An assumption made for Kelly betting is the bets are independent of each other. That's not the case in the problem given.

After making a bet, you gain information about the contents of the rest of the deck of cards. I could see it being possible to do better by pricing in that information into your bet.

  • amluto 4 days ago

    But the information gained in this game is independent of your bet. The multi-armed bandit problem is a famous example of the opposite situation.

  • necovek 4 days ago

    That seems to be exactly what this strategy is doing: at every step, you account for the probability of the red or black card coming up, and bet accordingly (both the sum and the colour).

bell-cot 4 days ago

Interesting as a mathematical puzzle - but note that it's difficult to find cooperative, solvent counter-parties for "I can't lose" betting games.

dado3212 5 days ago

Very cool writeup, would’ve benefited from some LaTeX formatting.

  • jmount 5 days ago

    Thank you, and sorry. The Wordpress/Markdown path seems to be getting worse over time.

    • smcin 4 days ago

      How is the Wordpress/Markdown path getting worse over time?

      • jmount 4 days ago

        Mathjax used to be available more places. Jupyter used to respect spacing around h2 labels. Things like that.

lupire 4 days ago

Corollaries, by considering different deck shufflings, such as perfectly interleaved as perfectly separated:

  9.08 ~
         52/52 × 52/51 × 50/50 ÷ 50/49 × ... 2/2 × 2/1 
       = 52/51 × 50/49 × ... × 2/1 
       = 2^52 × 26!² / 52!
       = (52/52 × 50/51 × ... ×  2/27) × (52/26 × 50/25 × ... × 2/1)
and these equalities can also be directly verified algebraically

This also points to a non-"many worlds"/portfolio version of the prod of zero-variance.

Every bet is e/d, where e is current edge and d is current deck size. So every outcome multiplies the stack by (d + e × (-1)^i)/d, where is ±1, depending on win or lose.

Note that the product of all the values of d is constant, so we can ignore the denominator.

Since we know (from the OP proof) that the product of these numbers is constant for all shuffles of the deck, we can split a shuffled deck anywhere such that both parts are balanced red=blue, and the total (multiplicative) return over each part of the deck is constant across all shuffling of that part of the deck. (There are at least two ways to prove this part!)

This is gives a further hint toward another fascinating fact: over any span of the deck between points where the deck is balanced, the numerators of the bet results double-cover all the even numbers between the starting and ending deck size.

To see why:

* A loss after a loss has a numerator (deck minus edge) of 2 less than the previous bet, as the deck size decreased by 1 and the edge has inccreased by 1.

* A win after a win also has a numerator (deck plus edge) of 2 less than the previous bet, as the deck size decreased by 1 and the edge has decreased by 1.

* A win after a loss, causes a big swing in the numerator, exactly back to the largest not yet double-covered numerator that started the streak that just ended. Then the new win streak continues making the second cover of even numerators, until... a loss after a win jumps the numerator back to continuing the sequence of decreasing even numberators, which will get their second cover later when the later wins come.

Since the deck is balanced, the number of wins always equals the number of losses, as long as we consider the 0 wager on a balanced subdeck to be a loss, since it increases the edge like non-degenerate losses do.

(When the deck is balanced, edge is 0, so the return of no-bet is same as a win is same as a loss)

You can visualize the numerator changes like so: a crane is driving from 52 to 0. Its arm is pointing either forward or backward, and there is a counterweight of the same length pointing in the opposite direction. At each step, the crane arm is either pointing toward 0 and stretches another step toward 0, or points backward to 52 and shrinks (toward 0 milestone and toward 0 arm length), or it swings to the other direction. Whenever the crane stretches toward 0, the counterweight stretches backward, its end not moving relative to the ground.

Because the deck is balanced at start and empty deck is balanced, the crane starts and ends with a 0-stretch arm. The front side is either the frame arm stepping 2 steps forward at a time relative to the ground, or holding still while the backside crane arm shrinks closer, and the crane arm occasionally flips back and forth pointing forward or ackward. And vice versa for the counterweight.

Over the course of the drive, the crane arm end reaches every even milestone once pointing forward and once again pointing backward.

ed-209 4 days ago

why use a static seed on the random generator and could that be making this appear more interesting than it might otherwise?

  • jfengel 4 days ago

    The idea is sound. The static seed is presumably so the results are repeatable, but it works for true randomness. (Assuming you were permitted to do it this way, which you wouldn't be.)

moonlion_eth 4 days ago

I was like "oooh fun a card game" then was like "oh shit I'm too dumb for this math"

  • IAmGraydon 4 days ago

    You aren't dumb. You just don't have enough exposure to the prerequisites.

    • necovek 4 days ago

      It could also be both: though it's not necessarily that they are "dumb", but that the language of mathematics is something they can't get their head around, even if they can understand the concepts when described in spoken language.

      Eg. it's probably pretty easy to convince them that with 15 cards in a deck, out of which 5 are red and 10 are black, chances are bigger (and in particular 10/15 or ~67%) that they'll pull out a black card, and that you should bet more on this happening. If you happen to miss, you should only bet even more on black since the chances grow further — to be able to maintain this strategy, you only need to never bet too much so you have enough "funds" to bet all the way through (eg. in the worst case where the least likely thing happens: in my example, that would be 5 red cards coming up first).

      Putting all this reasoning into formulae is what math is, and I do believe some struggle with abstracting these more than others (which is why the divide does exist and why many people believe those good at math are "smart", which is very much not so — seen plenty of "stupid" mathematicians, even professors). Does not make them "dumb", but might make them "modern math dumb". A signal that someone can be good at math today is that they are unfazed with more-than-3-dimensional spaces (you need to stop tying things to physical world).

tooblies 4 days ago

It's really disappointing that the code examples aren't given in PyGyat.