Roulette & the Stock Market

A notable parallel

NTTP
17 min readJul 3, 2024
Photo by Free Walking Tour Salzburg on Unsplash

Traveling back to a long time ago in a ville far, far away, we find ourselves in Roulettenburg again, but this time equipped with a bit of code.

Alexis Ivanovitch, stake TWO golden pieces this time. The moment we cease to stake, that cursed zero will come turning up, and we shall get nothing.

The Gambler, F. Dostoyevsky

As a “Gambler General’s” warning to start, we don’t want to disappoint any readers… but we are not going to provide any “gaming strategy” on how to make money at the casino in this article. Alas, that is “far above our pay grade” as they used to say back in the factories of Old Detroit. Rather, we will be roughly comparing how a particular roulette wager behaves over time (probabilistically) as compared to a bearish and volatile stock market asset.

The babushka in Dostoyevsky’s novella The Gambler latched onto the strategy of wagering on “zero” in roulette for some reason fully known only to her and explained by D to his loyal readers, all while getting tangled up in the illogic of the newly addicted. Presumably, theirs was European roulette with only one zero on the wheel and not also a double zero as in the American game. So with the 36 red and black squares, the green zero would then imply 37 numbers on the spinning wheel, and the grandmother’s chance of winning at each spin was 1 in 37 if she bet on zero… somewhere between 2 and 3 percent per spin… a small-ish but still non-zero chance.

Here we present a less risky wager that takes into account the concept of “design of experiments” and maximum coverage of desired test conditions with each experiment à la Taguchi

[https://www.itl.nist.gov/div898/handbook/pri/section5/pri56.htm]

and similar methods in engineering and manufacturing design. We are also enamored of the term and concept of the general Latin Hypercube method

[https://en.wikipedia.org/wiki/Latin_hypercube_sampling]

for this efficient experiment coverage, and we encourage readers to take a look at it. Such efficient dimensional coverage concepts are not limited to physical products, for mathematical models as found in machine learning and even generative A.I. could use ways to reduce the number of parameters required to properly “cover” a model space. After all, a mathematical model is a product as well that could often use optimization. There are hints of trillions of parameters in the latest A.I. models coming out soon. Need to whittle those down.

In this more detailed Monte Carlo (née: Roulettenburg) analysis — which covers both 1) expected long term win values that simple hand calculation does, and 2) also the volatility of those expectations (which is maybe not so simple to do with hand calculation) — we show similarities between a particular wager in a pure game of chance, and bearish but volatile stock market assets.

Since we are writing this in the Continental U.S., let’s use American roulette with its additional double zero, which tilts the odds slightly more in favor of the “house” and slightly more away from the gambler himself versus the Euro game. It is fortunate for Alexis Ivanovitch and his entourage that they were gambling in Roulettenburg and not Atlantic City, for the lack of the double zero square on Euro roulette tips the odds slightly more in favor of the player (though still towards the house). There is the small problem that Altantic City’s casinos may have not existed at the time that Roulettenburg as holiday destination was in fashion in the Russia of the mid 1800s, but we will leave that for Doc and Martynka to sort out in the (original?) Eastern Bloc version of Back To The Future: [“You made time machine? Out of ZIL?”]

A particularly rare ZIL limosine sans flux capacitor. Photo from: https://www.autoevolution.com/news/russian-zil-limo-that-belonged-to-mikhail-gorbachev-is-so-big-it-doesn-t-fit-in-photos-218463.html

What would have happened to poor Alexis if the slightly lower probability of winning due to the double zero tipped him out of the black and into the red even more than he had already experienced?

Instead of the fictional(?) Russian grande dame putting her two gold coins on zero, what we want our simulated gambler to try is to put one chip on red and one on even for every spin. Not to be too obvious, but this is a wager of two chips per spin.

We don’t really know from roulette, but we do know that to bet 1 on even and 1 on red, you put a chip on each of the arrow-annotated squares as shown above.

And, if he wins on a spin, he takes all the winnings off the table and then re-wagers the two chips on the same red+even squares for the next spin, and then again for all future spins of the wheel. If he loses, he digs into his pocket and plunks two more chips onto the table, again on red+even. Let’s say we do up to 100 sequential simulated spins for now. That will be more than enough to show what we want to show.

We marked up a roulette wagering grid with yellow dots and can count how many squares of the roulette wheel are “covered” with this two chip wager:

Original image without yellow dots… from MGM Grand I think.

Base level “expected value” probabilities

First, we yellow dot all the red squares, since we bet on red. Then, we yellow dot all the even squares in the main 36 number grid (we don’t dot the zeros even though they are “even” in a mathematical sense, because they count as neither red nor black in this game). Notice that some squares will have two dots.

The losers

There are so many dots that it may be easier to count the non-dotted squares first:

(8 red/black cells + 2 zeros) of (36 + 2 zeros) = 10 of 38

Hence, there is a 10 in 38 chance of none of our covered numbers coming up. This is the probability of losing entirely on each spin of the wheel, 10 in 38.

Thinking the other way, with our proposed two chip wager, we “cover” 28 of the 38 squares. Not bad coverage with two chips, right? This is where the analogy with design-of-experiments comes in, for we do two “experiments” (chip placements), and with these two, we can cover 28 of 38 squares on the board with each spin. These are two very efficient experiments! This is like doing two tests of a device or product and covering 28 of 38 test conditions that we want to study. However, only if the ball lands on a number that has two yellow dots will the payoff be positive for us; the single yellow dot squares end up being break-even for that spin. If this is not obvious to you, run through some scenarios in your head. We’ll do one for you here:

Let’s say that the ball lands on 23, which is red, but not even. So then your red bet wins, but your even bet loses. Hence, net zero win: break-even.

The winners

Now we list the two-dotted cells, the cells where our red+even bet does double-duty:

14
16
18
30
32
34
36

This is 7 cases, so it represents 7 out of 38 = the chance of winning at each spin. This is significantly less than the 10 / 38 chance of losing at each spin, verifying the whole idea for this two chip bet that “the house always wins”… and we must always add to this: In the long run, on average. As we will demonstrate, short term wins in roulette are possible, though not highly probable.

From imdb.com for Pirates Of The Caribbean movie franchise. The author is uncertain which particular film this quote is from, but the reader is encouraged to investigate. Savvy?

If any of the single yellow dot numbers show up in a spin, it is a break-even spin for us. One of our bets (red or even) wins, and the other loses. Break-even count is then (38–17 = 21).

Let’s summarize in precise integer ratios:

10/38 chance of losing at each spin (in the long run)
7/38 chance of winning at each spin (in the long run)
21/38 chance of breaking even at each spin… one win, one loss

If you prefer your probabilities to be in approximate decimals rather than precise integer ratios, these are:

26.32% loss
18.42% win
55.26% break even

Table 1

The technical versus the everyday meaning of expectation

The above are the long term “expected value” numbers if you do this wheel spinning over and over. However, as we noted in our earlier stock market focused articles, expected value is a statistical term that does not have the same meaning as the common everyday connotation of the word “expected.” We “expect” the sun to rise tomorrow. We expect it with no variance, or a variance of almost zero. Certainly, we expect the specific sun rise time to vary depending on a bunch of astronomical phenomena, and if we are in, say, Michigan, we might not actually see the sun due to the preponderance of heavy gray lake effect clouds that often obscure the sun and make it seem darker than a solar eclipse at 98%. But think tilt of earth versus plane through earth’s orbit around the sun, the latitude you are at on the earth, and so forth. But sun rise time will not vary randomly; it will vary according to physical laws that we understand to high precision.

This is not what expected value means in statistics, however. In stats, we can and do have expectation, but often with wide variance, and this variance is what we will demonstrate with the following chunk of code. For example, the S&P 500 (captured by the Exchange Traded Fund SPY) has an annual volatility

(volatility = square root of variance… and it is indeed unfortunate that both volatility and variance both start with “v” [contributing to pedagogic confusion], seeing that they are far different from one another in absolute value… unless they happen to be near numerical 1 of course)

far greater than its typical annual gain. We will not analyze this directly here, but let’s take the following stats from this market focused web site for an example:

In the last 30 Years, the SPDR S&P 500 (SPY) ETF obtained a 10.47% compound annual return, with a 15.14% standard deviation. It suffered a maximum drawdown of -50.80% that required 53 months to be recovered.

From: https://www.lazyportfolioetf.com/etf/spdr-sp-500-spy/

A note of precision: The concept of “drawdown” is not defined the same by everyone, and one should take that 50.8% number reported above with a grain of salt. “Drawdown” over what period? According to what criteria?

Now if we use the thumb rule that most returns are within +-2 standard deviations of the mean, 2 standard deviations of the above is about 30%, which is ~3x the reported annual return of 10.5%. +- 2 is 4 total standard deviations, implying a range of 60%. Hence, volatility dwarfs returns (60 >> 10), even in a good ‘safe’ ETF which attempts to track a large portion of the US stock market. SPY is not a “wildcat” ETF that tracks only risky lithium extraction or rocketship to Mars companies. Imagine how bad this return-to-volatility ratio is for risky stocks! With let’s say 10.5% return and +- 30%, one could easily say in colloquial English that we “expect” the SPY return to not be exactly 10.5%. We such high volatility, we “expect” (colloquially) that the precisely defined expected value (the statistics term) will not occur. Which is kind of a strange thing to say, but it does describe what is happening.

Before we continue on with the code, let’s mull the above percentages that we computed for our Roulettenburg red+even wager proposal. As we figured, there is a ~55% chance of breaking even with our red+even wager on each spin. Far better to break even than lose, don’t you think? A red+even bet will keep a player rolling a lot longer than putting those two chips on individual numbers. And breakeven benefits the gaming house also, because if breaking even keeps you there, you are more likely to purchase other things such as food, beverages, et cetera.

What we set up in code, in a chunk of Javascript belonging to a lightly formatted HTML page for output, is a monte carlo — or, excuse me, Roulettenburg — simulation that resembles how we simulate the forward in time behavior of a stock market asset in our MCarloRisk apps and web site, where we (at first) assume I.I.D. daily stock market returns (Independent, Identically Distributed), resample from those returns to generate monte carlo price (win/loss) paths forward in time, and then perform necessary aggregations to compute a price/probability/time surface forward in time. Readers of our earlier articles may recall that while we assume I.I.D., we do not assume normality of those returns as many models do, in a tip-o-the-hat towards reality, because: Spoiler alert, daily stock returns aren’t normally distributed. As you can find in our other articles, we do allow some violations of the I.I.D. notion in our stock market apps to model more sophisticated situations. These stock market models we go into in great detail in our prior articles and in the application documentation itself. In this article, we will demonstrate that a monte carlo forecasting model like this — based not on I.I.D. stock returns but on I.I.D. spins of the roulette wheel — will generate a price/probability/time forecast surface that looks remarkably similar to that of a stock market asset — albeit one that is “bearish,” (tending downward), with fairly high volatility. However, our SPY ETF shows that high volatility is not rare in the market.

If our roulette wheel is not “fair” (see proprietor Rick’s machinations in the film Casablanca to help out a poor dame who’s down on her luck), then of course our roulette samples are not I.I.D. or random in any sense when those particularly charitable interventions are going on. We do not consider this case here and leave that for fictional speculation. We suspect that the Bayesians among us could determine if a roulette wheel is fair or not, similar to how they are able to determine if a coin is fair or not; but by the time they did, they might get booted out of the casino along with their gridded notepads, HP41C calculators, and slide rules. So it’s best to assume fairness and leave the Gaming Commissioner — or perhaps Captain Louis Renault himself — to deal with any alleged fairness violations.

You will also be able to compute (via making and counting dots on a roulette table like we did here… or by more clever methods no doubt) that red+odd, black+even, and black+odd two-chip bets give similar probabilities versus what we describe and model here for red+even. You can easily adjust the code to consider these cases as well, if you are so inclined. Maybe we will do it someday also.

This code could also be set up to handle more general wagers, but roulette is a complicated game where you can put one pile of chips on the line in between two numbers on the wager table, or on the common corner of 4 numbers and et cetera… All sorts of fancy rules that we don’t fully know and which are not germane to our simple two chip bet. We didn’t set out to make a full roulette simulator here, but merely wanted to demonstrate some commonality between this game of chance and the stock market, for one type of wager.

In our computation, we only show the amount that this repeated red+even two chip wager can theoretically win/(lose), not any concept of a “wallet” containing net winnings (or debts for losings). Hence, our 2 chip bets come out of thin air (2 per spin) and would need to be accounted for if we were to get into “walleting”… if we dare add -ing to that “w” word. The two chip wagers are kind of like the “gas” of an Ethereum transaction, to use a crypto currency analogy. We need them to continue to make spins of the wheel.

https://www.investopedia.com/terms/g/gas-ethereum.asp

Is it ironic that something which uses electricity for power refers to “gas” (presumably short for gasoline), isn’t it? Anyone for petro-crypto-currency?

Remember that we only bet two per spin; we do not let any winnings roll over to the next spin in this model. It might be interesting to see what happens to our win probability forecasts if we allow winnings to roll over from one spin to the next. Perhaps another time. And due to our particular wager here, we noted that we can either lose two chips, break even, or gain two chips after each spin of the wheel. Hence, our output winnings distribution over time is in increments of two. We can never win or lose one at a time with this red+even wager.

An amusing test of ChatGPT and similar “world changing” A.I.s would be to feed it this code and tell it to replace the red+odd bet with black+even and see if it gives the proper answer. Or black+odd. Or any other interesting bet. Or have the A.I. modify the code to let any winnings “ride” on the red+even so we can examine the winnings/probability/time surface therefrom as we do here for red+even. Can an A.I. do that? If so, color us impressed. If not, well… there’s your fancy A.I. for you.

The HTML with embedded Javascript for this article is hosted here.

The plots

Similarly to our stock market risk analyzer, we plot the 5th percentile constant probability curve at the bottom in red, and the 95th percentile probability curve at the top in green. We also plot the 50th percentile curve in black. We use different colors in our stock market analysis app for these curves than this web site does here. We should probably change this example to color match… as time permits, as time permits.

Win results from our 100 spin monte carlo forecaster for American roulette, red+even wager. The grey curve shows the results for a particularly unlucky chap.
Here is the same analysis, but the grey random curve is for a luckier chap who might-shouldda left the table at about spin 46.

This 5% to 95% range is where we will, 9 out of 10 times, end up between, over successive spins. So we can see that even though the trend of the expected value (black curve) is downwards (indicating loss for the player and gain for the house over time), there is a non trivial probability for the player’s winnings to be above the zero loss line. Let’s look at spin 9.

First part of output table below the envelope plot. Last line is spin 9.

It shows 5th percentile at -8 and 95th percentile at 6, a ratio of 6:8 (win to lose).

spin 30 5th = -16 mid50 = -4 95th = 10

But now if we go out to spin 30, we see a ratio of 10/16 or 5/8… tilted even more toward the house the longer we play. Ah. So. Of course this must be true. If a gambler could play longer and overcome the house’s advantage, this would be bad for the house… except perhaps in terms of food and beverage sales.

Further, as we inspect the green versus red curve, we see that the green (lucky gain) curve flattens out over time faster than the red (unlucky loss) curve does… the red loss curve keeps going down and down, indicating that if you are really unlucky, this red+even wager which in fact does cover a lot of the roulette table can still lose you a lot of money. This is no insight in general, but here we quantify it more than usual: We show not only the long term expected values (as in Table 1 above) with this plot, but also the variance over time, which widens (vertically on this graph). Not only is the expected mid-range value (to the player) tilting downward over time, but the “having a bad day” red loss curve tilts downward much worse than this.

However, the fact that the green curve is so high above the flat zero win axis and also above the “house always wins” slightly descending black curve shows that — even though the house always wins overall, and the game probability is tilted towards the house — there is a non zero chance that the gambler can end up ahead of the game in roulette with this red+even bet…. but not with high probability. This is not to encourage gambling as an investment, but it is to state facts and show the commonality with stock market models of this nature. Here we see that this particular red+even bet in roulette acts like a bearish stock with fairly high volatility. The volatility is higher than the downward trend, and so it is possible to come out ahead using this roullette wager (though with far less than 50/50 chance). Alas, it is also possible to come out way behind if our hapless gambler — teeth clenched on cigar long extinguished, sweat beading on forehead, necktie loosened — starts tracking that unlucky heavily downward sloping red curve.

The contemporary singer Perry covers this rags to riches to rags oscillation in her “Waking Up In Vegas” short film with musical accompaniment, also starring the Everyman actor Joel David Moore playing the lucky schlub riding the wave of volatility and fate with Perry, sneaking “you gonna eat that?” remnant breakfasts off of discarded hotel hallway serving trays:

https://www.youtube.com/watch?v=1-pUaogoX5o

We also plot a random single monte carlo path in grey. This will be different each time you re-load the page in your browser, since it is random. This represents the winnings result of a single monte carlo path of 100 successive spins of the virtual roulette wheel with our two chip red+even bet. We see how the path typically wanders up and down over time. Occasionally it will blast off up towards the green. Occasionally it will dive toward the red loss curve, fast. This is the more common experience of roulette. Sometimes you’re up, sometimes your down. Sometimes you have a winning or losing streak… but you may be able to see if you repeated refresh the page of our code that these streaks or trends can come from completely random circumstances and are not be predictive, as we also demonstrate in our stock market models. E.g. even if a winning streak starts, this does not suggest that it will remain as a winning streak. This is must be obvious to most readers.

In the table below the plot on the web site, we show the precise values that the monte carlo algorithm computed for these percentiles, and we do some computation of how often we hit zero and double zero versus the theoretical math to check if we are using enough monte carlo runs (100k in our example code).

To examine the code on how we do this, you can just go to the link in a browser and do a View Source (located in various browser menus in various places). We didn’t mangle or compress the code, to enable easy viewing. Also, we are a fan of vanilla Javascript, so there’s no overly complex frameworks involved in this site. In fact there are no frameworks at all, but we do pull in the famous ChartJS library for plotting. There are no parameters to adjust on screen, we just wanted to share the code in case you wanted to mess with it.

A 100 day backtest of the currently bearish asset SH model (inverse S&P 500 ETF) in our MCarloRisk3D app, showing its bearish expected value nature in the downward sloping bright green curve (these are past expected values [oxymoron?] since this is a backtest), and the overall fairly high volatility with a downward trend. Blue curve is reality. Compare the overall envelope shape to our above monte carlo analysis of a red+even wager in roulette.

Summary

In this more detailed monte carlo analysis that covers both expected long term win values as simple hand calculation does, and also the volatility of those expectations (which is not so simple to do with hand calculation), we show similarities between a particular wager in the pure game of chance of roulette — discarding any interventions by mysterious men with a past— and bearish but volatile stock market assets. There is the joke that the stock market (to ordinary investors day trading on a whim using apps like Robinhood and others) is the world’s biggest casino; our little analysis here shows that this joke is closer to reality than the jokesters themselves may intend to imply.

Addendum

If you tire of roulette and its fixed probabilities, you might want to take a look-see on the Q.T. as to what’s going down at the horse track, where the odds might-could be a little more flexible:

https://www.youtube.com/watch?v=BAIlVCStp3c

Hacking hints

  1. You can download or “Save As” the redeven.html file, modify it, then just open it in a browser with File Open. This file does not need to run from a server.
  2. We have a partially working “save probability distribution” feature available (triggered by the ‘save distrib’ button that doesn’t really look like a button on the upper left of the displayed page). It may only work on some browsers. It is hardcoded to output the monte carlo results to a file for spin index 39 now (starting at count 0), in case you want to examine the win probability distribution at different spin counts using other statistics tools. We like free Gretl: https://sourceforge.net/projects/gretl/

As usual, if any readers see any issues with our code or analysis, please let us know in the comments!

Further reading

Find Part 2 here:

https://medium.com/@nttp/roulette-the-stock-market-part-2-809e9efd48f6

Reference

https://www.venetianlasvegas.com/casino/table-games/roulette-basic-rules.html

--

--