Hacker News new | past | comments | ask | show | jobs | submit login
Monte Carlo methods – Why it's a bad idea to go to the casino (easylang.online)
431 points by whereistimbo on July 5, 2019 | hide | past | favorite | 161 comments



It's more complicated (worse) than this. That the house has a small edge only tells a small part of the story.

When people go to vegas for a weekend, they might have a number in their head they are willing to gamble. If they dont, then that number is their bank account balance. Then they start flipping coins, and often they keep doing this until they go bust. They rarely cash out when up but they always lose when they go bust. They scale the bets as their bankroll grows. Essentially they are flipping coins for infinite time and just waiting to get a bunch of tails in a row, which is inevitable. The behavioral factors are bigger than the house edge.

The idea that people are rational is also absurd. Some people are driving to the slots _because_ they are depressed. Or they are there for fun but they lose a bunch of hands in a row and tilt and now they're betting everything on a longshot to win it all back and win some because they dont want to self-identify as a 'loser'.

You can only spend so much money on drugs and sex. Gambling is the only vice where you can lose billions. And these days, all you have to do is pull out your phone to place a trade or a bet.


You hit the nail on the head. If you simply play the pass-line and free-odds on craps, the house edge is extremely small. And yet, most people lose far more than predicted by the odds. The problem is exactly as you stated - people don't have a defined exit-strategy, and their implicit exit-strategy is to keep playing till they lose everything. Which is guaranteed to happen 100% of the time even if the house-edge was 0.

An approach that I've found to be useful, and have personally used in Vegas:

- Always start off each session with a fixed $X in chips, even if you're flush from previous winnings

- If at any point during the session, you get to $2X or $0 in chips, end the session immediately and cash out everything. Even if you're on a "hot streak"

- Bet large enough that you will get to $2X or $0 in a short/moderate period of time. The longer your session drags on, the lower the likelihood of getting to $2X

- Once a session has ended, have a cooling off period. Eg, no further gambling until after the next show/meal

If done right, gambling can actually be extremely cheap. With a house-edge of 0.5%, you can gamble $10,000 and only lose $50 on average. This makes it far cheaper (and more exciting) than eating out or going to shows.

The usual disclaimers still apply: only gamble what you can accept losing, no more


I rarely gamble, but when I do I like the following strategy:

Start with X. Whenever you get above X, skim the surplus and store separately.

You've now capped your losses at X (aka the price of the game night) and feel like you're winning when you can skim some money off your pool.


One of my undergraduate roommates was stationed at Nellis AFB for an extended time. He and his wife learned to count cards and played in the same manner as the MIT team.

They took only their winnings and used it to buy entertainment in the casinos where they gambled, which went a long way with the military discounts.

I want to say their original X was $500 or so, and it funded several years of local entertainment.


In my 20s I’d just drop a $20 into a slot machine per day and play max bet, usually $3. If anything won it was a lot more than $20 and I felt like a winner. My rule was to spend the winnings immediately, and I still have a dkny vest I bought in MGM grand with my “winnings.”

I think gambling can be fun if you limit yourself and don’t take it seriously. Trouble is Vegas is good at making you feel special. And they serve free booze.


You can bet Don’t Pass and have everyone glower at you, but have even better odds.


People also glower and complain when you play perfect strategy at blackjack ... most people are utter shit at odds and statistics in a distracting environment like a casino.


My strategy used to only play perfect blackjack strategy at the very rare $5 or more typically $10 table. But it's not even fun when people get pissy about when they think you "messed up the cards." I've tried to explain and realized not even worth your breath.


The first two paragraphs of this story from "Surely You're Joking, Mr. Feynman!" illustrate your point well:

> The first time I was in Las Vegas I sat down and figured out the odds for everything, and I discovered that the odds for the crap table were something like .493. If I bet a dollar, it would only cost me 1.4 cents. So I thought to myself, "Why am I so reluctant to bet? It hardly costs anything!"

So I started betting, and right away I lost five dollars in succession--one, two, three, four, five. I was supposed to be out only seven cents; instead, I was five dollars behind! I've never gambled since then (with my own money, that is). I'm very lucky that I started off losing.

One time I was eating lunch with one of the show girls. It was a quiet time in the afternoon; there was not the usual big bustle, and she said, "See that man over there, walking across the lawn? That's Nick the Greek. He's a professional gambler."

Now I knew damn well what all the odds were in Las Vegas, so I said, "How can he be a professional gambler?"

"I'll call him over."

Nick came over and she introduced us. "Marilyn tells me that you're a professional gambler."

"That's correct."

"Well, I'd like to know how it's possible to make your living gambling, because at the table, the odds are .493."

"You're right," he said, "and I'll explain it to you. I don't bet on the table, or things like that. I only bet when the odds are in my favor."

"Huh? When are the odds ever in your favor?" I asked incredulously.

"It's really quite easy," he said. "I'm standing around a table, when some guy says, 'It's comin' out nine! It's gotta be a nine!' The guy's excited; he thinks it's going to be a nine, and he wants to bet. Now I know the odds for all the numbers inside out, so I say to him, 'I'll bet you four to three it's not a nine,' and I win in the long run. I don't bet on the table; instead, I bet with people around the table who have prejudices--superstitious ideas about lucky numbers."

Nick continued: "Now that I've got a reputation, it's even easier, because people will bet with me even when they know the odds aren't very good, just to have the chance of telling the story, if they win, of how they beat Nick the Greek. So I really do make a living gambling, and it's wonderful!"

So Nick the Greek was really an educated character. He was a very nice and engaging man. I thanked him for the explanation; now I understood it. I have to understand the world, you see.


I don't usually gamble, when I do it is roulette. Easy rules ans I only play the probabilities.

I also the approach you mentioned above, never more than say 20 bucks with maybe another 10 as hard reserve. Quit when I'm ahead by a factor of, again like you, roughly 2x. And playing smaller amounts, meaning not everything at once but reasonably high, provides enough entertainment gambling for at least an hour. So in the end, even if everything is lost, I had my fun. And let's be honest, 20 bucks for on hour of fun isn't that bad a deal.

Fun fact: In total I'm like 100 bucks on top right now, paid for a pair of Nike sneakers for my son back the day!


Roulette has the worst odds, so what do you mean by “playing the probabilities?” Roulette’s big draw is that it’s simple, high suspense, and visceral due to being able to see the ball bounce around

Personally, my gambling strategy is simple. Whatever amount I’m gambling is considered spent in exchange for the “fun” I get. I expect to walk away with zero. If I’m winning I like to go double or nothing right before I leave on black at roulette, just for the hell of it.


> enough entertainment gambling for at least an hour. So in the end, even if everything is lost, I had my fun.

I wonder what you find entertaining/fun about this. I've been to casinos a couple of times. The only parts I found entertaining were observing people and the free drinks.


Once every two years it's kind of fun. And playing the odds, well sure probabilities are low, buts that's what is to understand about it. By no means as complex as, say, blackjack. And I like to have at least a slight idea of what I'm getting into. Blackjack, no chance. Roulette, at least I know the odds up front whatever they may be.

And yes, the other people are the sometimes the funniest part. And the saddest. Seeing people using what is my month salary in around two hours... On the other hand playing only one or two bucks per game and others reaction is fun.


"Money won is twice as sweet as money earned."

Paul Newman - The Color of Money


There's even been a study where (IIRC) they gave people $20 for free, and they could bet on coin tosses. There was no house edge and the rules were set up so that with a basic understanding of probability and bet sizing they'd be able to cash out free money. IIRC 33% went bust.


This isn't a surprise, nor is it evidence of individual greed or stupidity. What's wrong with betting when there is no house edge? In which case, some people are inevitably going to wrongly pick heads or tails and thus lose their $20.

Had the OP actually properly described how to build a useful Monte Carlo simulation, you could find your article, get the actual rules, run a simulation and check whether 33% was in line with expectations.


Can you explain what you feel playing a game that will always make you lose money no matter the strategies and anything else? Very curious


Luck is lumpy.

Weirdly I seem to do quite well in the casino and often have evening where I leave the casino 2-3X ahead of where I started.

My luck at football betting is terrible, I'm even worse at horses.

When you're up it's quite the thrill. You weather the downs as a cost associated with the particular vice.

I enjoy "emotionally hedging" sports events - if I want X to win I bet on Y

Do you play any other things (sports or games)? Do you not ever go for low percentage / high risk actions if only for the pleasure of occasionally see them come good?

Think bicycle kick in football, haymaker in boxing, high stakes play in poker, 1-frame combos in Street Fighter, technically difficult riffs in a musical jam.

I feel your line of questioning locks money and all its uses to rationality. Money can be an instrument for pleasure and for many, risk-seeking is a pleasurable activity.


Poker and sports betting have a huge difference. It is not 100% certain you will lose long term. Thus can be pleasurable to me. Certain loss simply can't be and that's why I am curious


> It is not 100% certain you will lose long term. Thus can be pleasurable to me.

Is betting your job or an entertainment for you? If you see it as a job, a means to make money, I feel like that's unhealthy.

When I go see a movie, even if the money is "lost", I still enjoy it. You go to the movie for the emotion it makes you feel, just like you bet for the emotion it makes you fell. It's the trill, the chance of seeing big wins.

At the end of the day, casino can be actually quite cheap if you don't bet too high and there's free drinks too usually ;).


the emotion you feel in the movie or buying any product is the product. The emotion you feel in Roulette is not because you find roulette spinning beautiful but because you think you can win money when you can't. I still don't understand


> The emotion you feel in Roulette is not because you find roulette spinning beautiful but because you think you can win money when you can't. I still don't understand

Sure that emotion is simulated, you won't actually win money. The same is true for the emotions you feel during a movie. The fear you may feel in a horror movie isn't real, you aren't in any danger.

In both case though the emotion is really there and that's what you pay for.

That's exactly why loot boxes are essentially gambling even though you get no monetary gains from it. It plays on the sames emotions, the same thrill.


In the movie you are certain that this is not happening. In the roulette your mind actually thinks that you won. When you win $500 in the roulette you think you have won whereas you actually lost money by playing and you are riding some random fluctuations. Few people can intuitively understand the concept that when you win money at the roulette you actually lost $0.2 per spin in a $1 roulette multiplied by the times you spinned.


The other thing is that "winnings" feel like a different type of money. If I win at the casino, I cannot wait to spend that new money. Whether it's buying my friends drinks or buying some item that I wouldn't buy with regular money.

It's really fun to spend money that you feel just fell from the sky. If you employ the right strategy you will still come out ahead 40-45% of the time, and those times can be quite memorable and fun.

You will definitely take losses in the long run but if you play well within your means, they won't have any impact on your life.


Fair enough, but gambling can be social and other times it can be a "cheap" thrill


I've never been to a 'proper' casino, but I've seen a few in James Bond films.

Everyone is attractive, powerful and sophisticated. People look on, impressed at his daring. Everyone has a bow tie on. Beautiful women hand him free drinks with a smile. The atmosphere isn't even slightly tinged with the desperation and regret of gambling addicts.

I can understand losing $50 a day to live out that fiction.

I have no idea whether any casinos offer that experience - the gambling things I've seen in my country have all been far more tawdry.


The people in casinos are usually senior citizens carrying their oxygen tanks between slot machines.


And the slot machines are online ads incarnate.


I think of them as video games that are really simple, weird and boring.


Lol, at least the casinos I’ve been to in the US are nothing like this at all. Like basically the polar opposite.


Any game/activity that you have to join a club and pay a membership for (i.e. Golf, Tennis) and also play professionally would qualify, so a subset of entertainment, engagement, excitement, relaxation, thrill.


>>Gambling is the only vice where you can lose billions.

That is not far from truth, I use to work for a company that owned several Casinos, we use to have "whales" spending more than 100k each month, sometimes they lost everything so quick that we gave them 50% back or trip to Bahamas / Paris, Anything to keep them happy and coming back.


All true, but also this article is about Monte Carlo numerical methods rather than actual casinos.

"Flipping a coin until you get enough tails in a row" is a really good way to describe long term gambling, though. I'm gonna borrow that.


The history of probability theory and risk management is filled with mathematicians who were gamblers or had patrons that were. Introducing monte carlo methods with gambling seems very appropiate considering the history of the topic!


Indeed! Here's a Python notebook illustrating both Monte Carlo and symbolic analysis of historical gambling problems (the Chevalier de Méré corresponding with Pascal, Pepys corresponding with Newton)

https://risk-engineering.org/notebook/coins-dice.html


That's a nice course you got there. Thanks for sharing!


Thanks for reading!


> "Flipping a coin until you get enough tails in a row" is a really good way to describe long term gambling

It's not. The correct way is saying 'flipping a weighed coin'. It can be weighed in or against your favor. If it is weighed in your favor, then you will never really have the 'until' part (i.e. get bust), if you also manage your bankroll wisely.


I think they're referring to the psychological component of gambling. Most people only exit when they go bust, i.e. when they get sufficient consecutive tails to wipe out their budget.

That's how I read it, at least.


This is a common misconception about why casinos win. That 'casinos have infinite bankroll so they cannot lose' isn't actually an argument because casinos have limited bankroll.

If they would allow me to play a +EV game I can crush them even if they had infinite bankroll by varying my betsize. The 'random walk' argument only works for fixed bet size.


I actually made a simulation of this because it seems obvious - you can actually double your bet each time you lose, and this basically guarantees that you eventually win each time!

Turns out, you have to go surprisingly high for this to be true/effective on the long run. And the casino will cut you off way below the limit (i.e. there's of course a maximum bet). Plus, with this strategy, each win is a small one... but when you lose (hitting the max bet), the loses are significant.


> I actually made a simulation of this because it seems obvious - you can actually double your bet each time you lose, and this basically guarantees that you eventually win each time!

This is the St. Petersburg paradox: https://en.wikipedia.org/wiki/St._Petersburg_paradox


The expected value of that strategy is still negative. You get a high chance of winning 1 dollar, with a low chance of losing everything. Only the chance of losing everything isn't low enough.


Yeah, the doubling of your bet tactic when you lose is an old Blackjack strategy. But with the introduction of a max bet you have to look at the scale difference between the min/max bets, usually it means for example that you only need to lose 5-7 times in a row to lose everything.


> If they would allow me to play a +EV game

If a business offered a positive EV gambling game, it wouldn't be called a casino and would only last as long as the venture capital lasted.


Actually there are still +EV video poker games in Vegas.

http://www.slotsmamma.com/blog/how-do-you-find-full-pay-deuc...

There are a few catches though. Mostly if you play perfectly (which is not simple) the most you can expect to make is less than eight dollars an hour.


That's a good job for making the casino look more active. Just letting someone win $8/hour


People playing until they go bust doesn't actually affect the casino's take, except insofar as it means more people are gambling. If someone leaves when they're up and someone else takes their place at the table, the casino makes exactly as much money as if the first person hadn't left.


This would only be true if all the seats in a casino are at or close to fully capacity, which in my experience isn’t true. Also only true for games with a fixed amount to bet


Yeah. I think casinos would prefer not to inflict financial ruin on their patrons. Apart from the bad PR (and potential for political interference), a bankrupt patron seems less likely to come back to the casino with more money.


That's true, We used to give free credits/ chips if they lose too much too quick. Casino's want long term relationships.


> If they dont, then that number is their bank account balance.

Given that not everyone's account balances are zero, plenty of people gamble for entertainment without going broke. I'm occasionally rational and enjoy playing craps. It is social, rolling dice is fun, and it gives a huge range of betting opportunities. I will also almost always play until I lose. The point is to have fun playing, and not to win money at a game where my EV is negative.

If I want to win money, I play poker. The problem with poker is that I'm not good enough to play games where I can win big (10s of thousands) money. The second problem is that playing winning poker is a grind and can be quite boring.


It's called martingale strategy. The same strategy is embedded into incentives in the wall street compensations.

The real cause of the financial crisis -- An MIT Blackjack Team perspective by Semyon Dukach http://semyondukach.blogspot.com/2009/01/real-cause-of-finan...


Sadly, people do the same in the stock market too. And I’ve seen the same result - lots of tails crushing someone’s financial future.

Sad how prevalent this is. At least I have to fly to Vegas - the stock market is on my phone.


It's mind-boggling how gambling is legal.


The other potential vice is non-control stock market and purely monetary investments, which shares many of the features with gambling. Lack of transparency, design to take your money and not pay dividends, being unable to actually change policy of said organization. Also lies and marketing.

This opposed to physical, direct investments which are much easier to control, but more labor intensive. Control stock (as in having a control stake) is in-between, and extremely rich people game.


Sure, but lots of people can also gamble a little bit and then quit.


"You can only spend so much money on drugs and sex."

I beg to differ, good sir.


> You can only spend so much money on drugs and sex.

Speak for yourself.


Who even plays slots. Sounds like some people are bad a gambling mate. /s

For those that do like to gamble and are not addicted, craps and live 4-8 no-limit hold'em table, 1-2 if you are new. As for pulling out the phone, Liverpool has given me a lovely year.


I have a pet peeve about Monte Carlo methods; although it might be more fairly characterised as a rookie mistake I saw once.

MCM are not strong if the tail variance isn't an important feature of what is being modeled. I've seen simulations where the modeler starts with an analytic model - from which they could trivially calculate the mean and variance of a KPI - then used a MCM simulation to find out essentially what the mean and variance of the KPI.

So I get that this code is just for illustrative, educational purposes. That is fine. Well done Christof, thanks for the contribution to education. But if anyone is actually using MCM to simulate well known probability distributions they should really put the effort in to learning how to work with well known probability distributions. I feel pretty confident that simulating the Bernoulli in a professional setting is a mistake, because I've seen it done and it was a mistake. For amateurs who aren't confident with math then they can use MCM if they like; but statistics is dangerous and they should be aware that they are using the wrong tool for the job and it is a tell they will get other things wrong. You get a lot of insight from a good analytic model.

If there is some interesting tail issue (eg, maybe after 3 heads there is guaranteed to be a tails and your insurance contract pays out on a tails) then sure, use MCM. Great tool if you have the right problem.


Well yeah MC is usually meant for problems that are otherwise intractable, e.g. sampling complex Bayesian posteriors, or solving stochastic differential equations.

Using it for an answer you could easily get analytically isn't very useful outside of education/fun.


I agree. Here's a Python notebook that illustrates this problem on a classical gambling problem, the Saint Petersburg paradox. The notebook explains why stochastic simulation methods such as Monte Carlo are not suitable for situations where a very unlikely event has a significant impact on the output of interest in your simulations.

https://risk-engineering.org/notebook/saint-petersburg.html


While I generally agree with what your saying, I think the MCM can be a great way to validate more accurate approaches. The primary advantage for validation is you can get a reasonably accurate answer with minimal effort.


Really dependents on your philosophy. Would you rather do error propagation using this method http://lectureonline.cl.msu.edu/~mmp/labs/error/e2.htm

or would you rather perturbate your variables and resolve mean and variance. My philosophy drives me towards the computational approach over the analytical mathematical approach.


Are you sure there is even a philosophical difference there? I'm still going to use a program to do the heavy lifting of calculating the errors. I'm happy to argue that there is no philosophical difference; if both approaches are feasible and take comparable amount of time to implement then one gets the exact answer to the question at hand and the other is a poor man's shortcut for people who aren't confident in their maths skills.

The calculations should be arriving at the same numbers in the end, and implementing a simulation vs. an error propagation tree isn't going to favour the simulation for simple scenarios.

MCM is great for when doing usual error propagation is infeasible. It is sloppy when the error propagation could be done with a one or two analytic formula. Simulation isn't appropriate for problems that are easy analytically. For example, in practice, most of the examples in the article are not suitable problems for breaking out MCM (and although the author probably knows that, maybe not everyone on HN does). The Pi one might be a standard application, but even there Pi in particular is not a great choice for a showcase because Pi has some very nice analytic approximations.


I think the value is in checking assumptions - if the analytical approach assumes a normal distribution and then you do MCM and get a vastly different result then it is probably worth checking the assumptions made by the analytical model.


That is an inappropriate way of checking your assumptions. Assuming a normal is assuming a model (a model is a simplification of a situation by only considering the relative parts). Writing a simulation is also assuming a model, although the process is a lot less formal than traditional statistical regression.

If a modeler has assumed two different models of a situation and are getting vastly different results then that is evidence something is wrong, but it is also evidence that the modeler is out of their depth. It is not appropriate to fit two different models and then claim that the differences are delivering insight. The differences are revealing big gaps in the modelers understanding of key influences, rendering both models highly suspect. They should not be creating models, they should be putting more time into understanding the thing they are modeling.

There are times when a modeler would have two different models, but they should certainly not be surprised that they give different results. Indeed, they should be assuming two different models because they are going to give completely different results. There will probably be other edge cases, but in my experience they are rarer than people just making mistakes about where MCM is appropriate.


If there is an analytic model, using Monte Carlo methods is extremely useful to validate the theoretical result. If both agree, it is unlikely that there is a mistake in the theoretical result: which is valuable information.

For something as straightforward as Bernoulli, where you plug values into a formula and are done, there is no reason to use MCM. However, I am in agreement that in more complicated cases (e.g. a probability distribution is based on some result of one Markov or Markov-like calculation — or possibly multiple), and the theory is slightly or much more complicated then there is a lot of value in Monte Carlo methods.


Can I ask if I understand your use of `tail` in tail variance? Do you mean tail as in extremes of a distribution, or tails, as in losses. I'm very interested in using MC techniques to model extremes of a distribution, like 1-in-1000 year events from a Weibull distribution, but my (naive) algorithms spend a lot of time in the fat belly of the curve rather than out in the tails, but perhaps (probably) I'm holding it wrong. Is there a way to constrain the MC sampling to the tails of a distribution?


I meant tail as in the extremes of the distribution. My point was more that once you've assumed that your events follow a Weibull distribution then the opportunities for MCM to add more insight are limited if the task at hand is to predict what the distribution and its parameters are. Obviously if you simulate a Weibull distribution you will get results in line with the info box on the Wikipedia page for the Weibull distribution, and you need to effectively assume parameters to simulate. Simulating a distribution just creates a very error-prone calculator the obscures the assumptions. I've seen people do exactly that thinking it was somehow helping - it is surprisingly easy to accidentally simulate a normal distribution, for example, because if you add a whole bunch of uncorrelated random things together (with identical distributions) then the result is normally distributed. You don't need a simulation to tell you that, and it is easier to mull over without simulation.

If I were using simulation it is because I think that something fishy happens in extreme events (eg, maybe stock returns all starting to become highly correlated in a liquidity crisis, destroying i.i.d assumptions). Or as other commenters mentioned because the thing being simulated has a distribution that is not analytically tractable. But there has to be some phenomena in there that is more complicated than standard distributions or a steady state Markov model, because they are more productive models when they work.

> Is there a way to constrain the MC sampling to the tails of a distribution?

You could sample 100 numbers at a time and drop out the middle 95? The question is maybe not well posed.


You want to look up about importance sampling. There are lots of ways to do it, the two most common are via scaling or translation.


I once was in a situation where I had to hammer in a nail with a screwdriver (grabbing it by the front, hitting with the grip). The feeling I had back then is one I all too often experience again in programming.

This example isn't so much different; MCM = screw driver, problem = nail and learning proper statistics = driving to the hardware store and buying a hammer.

The only aspect where the comparison is somewhat lacking, is that the costs of having a hammer (both aquisition and storage) are minimal compared to in-depth knowledge about statistics.


A while ago I wrote a similar interactive article to prove that the martingale betting technique at the roulette doesn't work : [1]. The martingale is when you bet 1, double the bet each time you lose, start again at 1 when you win.

The aim was to create a single page anybody could link to that proves without a doubt the abysmal odds of making money off the roulette with the martingale technique. Instead of pre-written probabilities, charts and 'obscure complicated math' that people could easily dismiss. I wanted to give people the ability to run simulations of playing at the casino in the browser. The idea being that people would end up building the probabilities/charts themselves through simulations.

It is running Monte Carlo simulations inside the webpage and outputs the result as charts dynamically using js and D3. What it does is it repeatedly simulates going to a casino with a certain starting amount of money and an objective of how much you want to win. It then plays the roulette using the martingale technique until you got your target winnings or you lost your money.

Unfortunately I don't think I wrote the article really well and the 'generate yourself the charts proving it doesn't work' doesn't come across really well. I should have put a 'run' button instead of needing a page refresh for a start.

[1] http://thomasburette.com/martingale/


Theoretically I learned it works, but only if you have unlimited funds.


Thing is, at any limited amount of funds it doesn't work. It's not like it works better as you get more funds. It just gets more volatile.


Doesn't even work with unlimited funds since casinos have table limits.


Wait, what could you win if you already have unlimited funds?


1 dollar, an unlimited number of times.


An unlimited number


"The market can remain irrational longer than you can remain solvent."


All of that is completely invalidated by that one time I hit 13 on the roulette table at two different casinos and quit gambling up $1500 ;)


Just a few varied anecdotes from working as a dealer and croupier for a few years:

I once saw 13 be hit 4 times in a row (and once more within my 45 min rotation at the nearby table). Don't think I've personally seen any other 4 number streaks.

A lof of people won a lot of money during the two last ones.

I've only played a few slot games online and visited a real casino as a guest once, where I bought chips for $150 and left with $5400. The goal was losing it all and at the end I was putting $1500 on the table at a time, and dipped below $500 just a few minutes before making the $5400 and leaving.

One of the best nights I had while working was a regular from the poker room coming to my Black Jack table trying to win back the $15k he was down. Had the 'chef' (senior position at the casino floor, poker equivalent would be 'brush') there talking to him since he wasn't doing well. He managed to win it back which was a great relief.


at first glance it is the exact opposite of using Kelly criterion


My experience of going to high-end casinos, mostly in London, is that:

- Many players were plainly cheating in some way, by marking cards and sometimes colluding with the dealer, but the casino didn't appear to mind because they were cheating in an ineffective way and still losing money to the house edge.

- (Related: you would just be banned if you won an amount of money that showed you were beating the house edge: see also the Phil Ivey lawsuit)

- Some players were gambling large sums of money generally on games with a small house edge, and looked bored like they were there to do a job. I assume from their behaviour they were laundering money.


European casinos I have found to be boring compared to American casinos. A craps game in an American casino can get raucous in a good, exciting way. Even more so at a 'cheap' American casino.

Contrast this when I was at the Monte Carlo casino in Monaco where they somehow sucked the fun out of craps.


Las Vegas-type casinos are definitely selling entertainment.

European casinos seem to be selling something else.


I work on Monte Carlo simulations professionally for casino slot games.

I wish that more depth was presented here: what percentage of the time do you get favorable vs unfavorable outcomes with each strategy? For further depth, use different types of players (with different exiting conditions).

Perhaps I should write such a blog post at some time..


That post would probably be of interest to a lot of HN readers. If you want, we can look over a draft if you send it to hn@ycombinator.com. Sometimes we can make suggestions that improve an article's appeal to this crowd.

Same offer goes for anyone else who's putting a lot of work into a post they hope will interest HN.


Thanks dang. I may very well take you up on this offer.


Please do, I'd love to read more about this!


When I was 8, I spent 6 months in hospital and that was over 50 years ago. Not much to do, so my parents made sure I had lots of puzzle books of all kinds as well as story books. One of those books had a chapter on gambing, which I found interesting, it was written for children. It made the claim that as long as the "bank" had a significant value greater than your own (by at least 10 times), you could not win against them even if the odds were 50:50. As the decades have gone by, I followed this up with other research and basically, gambling is a mugs games if you are not the bank.

Yes, you can at times win and come out ahead. But on the whole, you will lose. My father's advice has always been: "Son, treat it as entertaiment and spend only what you can afford to lose like every other form of entertainment. If you think you can win, you be the fool and will lose more than you can afford." I have also found that gambling institutions are so depressing a venue to be in.


I am even more impressed by the `easylang`[0] itself, which was used to create the demo.

[0] https://easylang.online/ide/


Blackjack on the strip has become a boiling frog of sorts. Everytime I go back the rules are tweaked a little more in the house’s favor.

3:2 payouts for Blackjack were gone years ago, but more recently no even money for Blackjack if dealer shows an Ace, only split once for two Aces...not worth it at that point.


In the handful of times I've been into casinos here in the UK I've always just stuck to the Blackjack table (I used to play it with my grandma for buttons when I was a kid). Every time I've walked away with more money than I started with. My biggest profit was over £500.

The one and only time I was convinced to give roulette a try I lost everything pretty quickly (I mean the small pot I'd set aside for gambling - I'm not stupid enough to keep withdrawing money and bet more than I can afford).

Seems blackjack can be pretty lucrative if you're willing to walk away at the right moment. I seriously doubt it would work as any kind of long term strategy, however. Of course you also have to have the discipline to spend the rest of the night drinking beer and watching your friends get poorer and poorer.


Pointing out the obvious: it's more expensive to run a modern resort casino than a Fremont St casino in the 50's, even in inflation-adjusted dollars.


Investing: Return on Investment > 0

Gambling: Return on Investment < 0

For the casinos, it's an investment, for the customers, it's gambling.


Perhaps we could combine the two? Make a slot machine that pays out in penny-stocks, rather than chips.


We call them "online brokers" :-)


I have similar simulation 10 years back written in C, no fancy description but understand how casino works.

Similar conclusion, once u win enough, you leave; once you lose enough, you leave. Never bring your whole bank account to a casino, or the figures will be move closer to 0.


If you go to a casino play poker with other humans. Nothing else is worth your time.


Even poker in a casino probably isn't worth it unless your opponents are obviously drunk or bad players. After the rake and the dealer tip, there's a good chance your edge is zero or negative.


I read parent as saying that playing poker with others is the most entertaining way to spend your time at the casino, since he didn't mention money.


This article should be down-voted, the only reason it isn't is due to the clickbaity nature of discussing casino games. It's a terrible initial introduction to Monte Carlo simulations, he doesn't even discuss the possibility of seeing the distributions of the results of the games he proposes, which is essentially the most valuable reason to perform a Monte Carlo simulation.


If you read it instead as an advertisement for easylang.online it's a pretty nice introduction for the language


...and if the headline was "Learn to Program in easylang.online" it never would have sniffed the front page of HN



another clickbaity headline, confirming my point


I do not understand your criticism. The main content is Monte Carlo simulation at Roulette and that you lose in roulette games. The headline says just that. "easylang.online" is in this case just a means to transport this content. It would be much harder to do that in JavaScript and the examples would also be less comprehensible.


Great article showing how easy it is to experiment with probability using Monte Carlo methods. You don’t need any fancy libraries or deep mathematical knowledge.

Of course you should always try to have a deeper understanding if you want to make serious conclusions. But I felt this article got the concept across really concisely! Nice work.


For people interested in applying Monte Carlo methods, here are some tools that make it easy:

- Causal: https://causal.app (I'm working on this, web app)

- Guesstimate: https://getguesstimate.com (no longer in development but very cool, web app)

- Palisade @RISK: https://palisade.com/risk (Excel plugin)

- GoldSim: https://goldsim.com (very technical, desktop app)


It's (relatively) easy to show the math on why casino games are impossible to win, but what about sports betting? Does the house always have the advantage? Perhaps it's slightly better for the gamer?

FWIW I was looking a betting website recently [0] and they were offering DOUBLE your initial deposit for signing-up, up to $1000. So to reiterate, they are willing to give up to $1000 for FREE just for creating an account. All I can imagine is that they would only do this if the numbers are vastly not in your favor.

[0] I'm not going to post the name of said website.


>> just for creating an account

No, for creating an account, funding it AND making a significant amount of wagers. The details vary by site, but there are always restrictions in the fine print -- either you only "earn" the bonus a few percent at a time, or you aren't allowed to withdraw until you've made enough bets, or some similar restriction. I'd guess that some or all of the "free" $1000 is inaccessible until you've made a 10x rollover, or $10,000 in wagers.


You have to bet the bonus money at least once.

I did this. Bet the bonus on some super low odds trots race to place that was as good odds as anything to get my money back and then bet the other half on a 36:1 long shot that Bernie would win the nomination.

I got my money back with the low odds Trotter, otherwise I would have bet the balance on another low odds event. Obviously didn't win the long shot.

Not sure why I did it as I don't normally gamble but generally curious and though it was a fun way to risk a small amount to potentially win a "free" holiday.


>Does the house always have the advantage?

The mathematics doesn't really matter because if you find a systematic way of winning then they just ban you.


So... yes?


The language they're using seems to pretty much be BASIC with slightly different syntax, it even lacks user-defined parameters for functions just like BASIC does.


There are user defined functions with parameters and locals.


Why have subroutines then?


Subroutines have a global namespace - this is easier to understand. Functions with parameters and local variables allow longer and recursive programs.


If you want to really know why you shouldn't gamble (for profit... gambling for fun, with discipline, can be satisfying), read this quintessential book:

Scarne’s Complete Guide to Gambling

What you will probably take away from this book is that the house wins when you win. And the reason they win is that they don't pay actual odds.

Take the roulette wheel as a simple example. There are 37 (or 38 in the case of 0 and 00 wheels) slots. If you bet on a single number, they pay 36:1.

TFA mentioned doubling down when you lose. That's known as the Martingale Strategy. As banks and real estate lenders discovered in 2007, regardless of your model, there will be some condition where the near-impossible will happen.

If you want to use the roulette wheel again as an example, and even if you want to ignore the green 0/00 slots, you have half black and half red. You can simply play one color and double your bet if you lose... until you finally win it all back.

The problem there is that while it's true that for millions of spins, about half should land black and half should land red... but in short periods it is possible for there to be 10 or 15 or 20 or more spins of the same color. We can all do exponential growth, so it's easy to see how doubling down will empty your wallet eventually.

But just to be sure that strategy won't work, most casinos will set a table limit. That limit will be designed to prevent you from doubling your bet too many times (5-7ish times? depends on the place). Of course, if you discuss in advance with the casino, you may be able to set a personal table limit based on your initial bet. So you can bet 1 million on the first spin in order to set your table limit to 1 million. But that's truly a gamble.

There is one element you can control when gambling: that is when you increase or decrease your bets, and ultimately when you stop playing.

Yes, you can count cards in blackjack; but that's generally frowned upon (where "frowned" means you will be escorted out and told to never return -- and they are very serious). Even levels of indirection of counting such as employed by the fascinating experience of the MIT crews of yore (https://en.wikipedia.org/wiki/MIT_Blackjack_Team) have become obvious. So the short of it is, unless you only play a little, bet big, and get lucky for your limited period (and then stop so you don't get banned), you will otherwise lose more than you win.

Now for my personal opinion :). Casinos used to be a fun place. Now they are so optimized and commercial that they are like Walmart. Yes you can go, but you'd probably rather not. For modern thrills, we now have crypto exchanges with 50:1 or more leverage.


From what I've read, casinos are perfectly happy to let you count cards in blackjack. The advantage you get is so small, that even a few mistakes per hour means you'll lose a bunch of money. It's only if you count cards and win that you get kicked out.


> From what I've read, casinos are perfectly happy to let you count cards in blackjack. The advantage you get is so small, that even a few mistakes per hour means you'll lose a bunch of money. It's only if you count cards and win that you get kicked out.

It's not that the advantage is small (if it were, the MIT team would never have been so successful in the first place). It's that most people who try aren't good enough to do it well, so the casino is happy to let them try (and fail), thereby making money for the casino.


It's also worth noting that the MIT teams (and successors) stopped circa 2000. Times have changed. Casinos are much more on top of what's going on on the floor.


Most casinos use multi-deck shoes (so multiple decks of cards in one stack which they deal from). Your counting advantage increases as the shoe gets smaller (more cards played, more history, more knowledge of odds of face cards remaining in the shoe).

Casinos will shuffle all the cards before you have a significant knowledge advantage. They may adjust their shuffle point based on whether they detect a counter. If there are no counters at the table, then it's more efficient (for the house - hands played per n period) to play until close to an empty shoe. But if they detect a counter, they may shuffle much earlier - half shoe even. At that point, the counter has very little advantage.

Regardless of the rules and what casinos choose to allow, they will stop a player that they believe will, over time, really hurt the house. In some cases, however, skilled players will be allowed to count and win big for a period if the house believes that player will take that money and lose it elsewhere on the property. Or if that player is influential and attracts/brings other less successful or disciplined whales, the house may ignore the cost of the one successful counter.

In the end, it's about bottom line... unless the player pisses off someone important on the property. In that case, it doesn't matter what the player does - they're gone, banned, and probably blacklisted from other quality properties.


Count? Yes.

USE the count? Typically no, unless you're betting very small and consistently.

Basically, the way to annoy them and either get kicked out or only allowed to flat bet is to vary your bet size with the count (E.g. bet a lot when the count is favorable, and the table minimum otherwise). That's the only way to really make money counting. Much easier to detect these days with the eye in the sky.

You can use the count to inform certain decisions that lower the house edge a bit, but typically not enough to actually be +EV. For instance, insurance is normally a very bad bet, but at certain counts it becomes +EV, but not +EV as a whole to make it worth...having to play blackjack.


If you use he high low system it's a +EV bet to take insurance when the count is +3. At that point the probability is greater than 1/3 that the dealer has a 10.


I was able to play martingale in a casino in a video game, so a limited wallet wasn't my problem, and I made money in the long run, but it exposed a subtler problem with Martingale: You only ever win your initial bet back; the rest is covering losses. If you have the cash to withstand 20 losses, then the initial bet, in comparison to your stake, is basically a rounding error. Who cares about winning $1 when you have $1 billion to martingale it?


Yes -- this is what is commonly misunderstood about Martingale. What Martingale really does is change the probability distribution of outcomes to be heavily weighted toward winning a very small amount of money.

You can, for a given number of plays, use Martingale to make the odds of winning greater than the odds of losing. However what you can't do, is change the expected value of that set of plays. So what you've really done is created a situation where you have a high chance of winning a small amount of money, and a low chance of losing a lot of money.


Yeah, I'm running the Martingale simulator in OP, and getting frequent outcomes where I was able to gamble 10+ days starting with $10000. I suspect that's what gamblers really like about it -- not more money, but more gameplay.

(There's also the gambler's calculus that while they're losing money playing, they're being comped drinks/rooms/meals/shows/etc at a resort.)


What's kind of funny is that lots of people talk about playing the Martingale, which is dumb, but no one ever talks about playing the reverse Martingale - which is also dumb and losing, but at least has what I'd argue is a more favorable outcome distribution. Basically, with a reverse Martingale you'll usually lose a moderate amount (which, I mean, is what you'd expect since...casino) but occasionally win a larger amount when you hit your winning threshold and get, say, 6 positive results in a row.


Plenty of people play like this accidentally, moving up stakes when they are winning.


Yes, that is also a problem. When you lose, your risk increases exponentially. Given an unlimited wallet and no casino rules, that's ok. But the real world unfortunately doesn't work like that. (And if you had an unlimited wallet, who cares if you lose?)

No matter what you bet, your take is only equal to your initial bet * number of rounds/hands played.


There is a pinball museum off the strip in Vegas.

Played until my wrists ached on $5.


Best part of the Strip. I make a point of going every time I'm in Vegas.


The Python examples are delightful! If you input them at

https://www.speicherleck.de/iblech/zufall-im-browser/index.e...

(with slight modifications), then you get continuously-updated histograms of the results.


I do not have a lot of background on statistics. Hoping someone here could explain why in Roulette game, although the apparent chances of getting number between 0-18 (inclusive) and 19-36 (inclusive) are the same, we lose money if we keep playing more and more numbers of games.


The 0 does not count as a lower number. There at 18 numbers in both the groups 1-18 and 19-36. Each of these give a 18/37 chance of winning, which is lower than 50% and therefore loses in the long run when the money is being doubled on a win.


Ah...I see. I am not much of a gambler either, so this is a very useful piece to know why Roulette gambling, in the long run, turns negative for the gambler. Thank you.


The subtitle made me expect something about a failure mode of MC methods in some popular application...


I made an effort to download previous draws form my local lotto website [1] And parsed them and applied a montecarlo method to see:

1. If I could find an optimal way of playing the game to maximize my profits.

2. If I could find a bias towards certain numbers.

The result was:

1. I found a way with 1/3 chance of winning big and paying back all expenses you played for the past 20 years. It is a significant investment and everyone will think you are crazy, but you have a very high chance of early retirement.

2. I found no obvious difference between the frequency of numbers.

The idea is to spread your betting numbers as far apart as possible in order to follow the normal distribution. If you reduce the overall gap between your numbers, your chances of winning is significantly reduced.

[1] http://www.millipiyango.gov.tr/sonuclar/_cs_superloto.php


If you found no difference on number frequency, it's the uniform distribution, not normal (a.k.a. gaussian) distribution.

AFAIK uniform distribution means any number is equally likely to be drawn, regardless of distance to your other picks.

Just to check if I got that right: does that mean that playing 333333 and 666666 in a 6 digits lottery had a higher chance of winning that picking 333333 and 333334? If so, why? And, since playing more numbers will reduce the overall gap. Does that mean the optimal strategy is playing a single number?

Did you test your method via simulation? I can't see how it works with my little knowledge of statistics. Can someone chime in?


Yes, I meant uniform distribution. My method was to give it a higher chance to have a lower gap between the numbers to see if it would make a difference within a montecarlo simulation and it did. So if you have say 16 slots and you need to choose four numbers, according to my simulation, highest likelyhood of winning is to spread out your numbers like [3 6 9 12] or [4 7 10 13] and lowest likelyhood of winning is to spread like [1 2 3 4] [2 3 4 5] all the time.

Not exactly sure why.


Huh, that's unexpected. I'll try to reproduce it, thanks!


Would love to hear about it!


It's absolutely obviously for people who know the basics of Probability theory. Not sure if modern high schools covers it now.

But it's only a part of the problem. Second part - money and gaming easily can be addictive like drugs.


Everything that makes your brain feel good, can be addictive.

Not the drugs are addictive, feeling good is.


Yes, that's what psychological addiction is. Make no mistake though, chemical addiction is very real. Alcohol withdrawals can be fatal


This actually taught me that the losing strategies win more often then we thought.

I got positive 2 our 4 times for the single 13 choice.

And for the strategy to double your bet to cover your loss actually worked for me!

Day 1: $10870 Day 2: $12980 Day 3: $10630 Day 4: $8190 Day 5: $7560 Day 6: $9100 Day 7: $9090 Day 8: $10130 Day 9: $12080 Day 10: $12870 Day 11: $12910 Day 12: $14110 Day 13: $15450 Day 14: $15030 Day 15: $15500 Day 16: $14230 Day 17: $13700 Day 18: $11190 Day 19: $12250 Day 20: $14190 Day 21: $16070 Day 22: $12880 Day 23: $12820 Day 24: $11480 Day 25: $12470 Day 26: $14920 Day 27: $9940 Day 28: $10240 Day 29: $9020 Day 30: $10740 Day 31: $12600 Day 32: $14880 Day 33: $17220 Day 34: $15700 Day 35: $17920 Day 36: $18150 Day 37: $14080 Day 38: $16150 Day 39: $18140 Day 40: $19960 Day 41: $20000 -------------


The American roulette wheel has 38 slots, which include a zero and a double zero. The French roulette wheel has 37 slots. The house edge on the french wheel is half of what it is on the American wheel.


I am very surprised that this is something that needs to be said in a hacker news site? Would there be community members here that don't understand basic arithmetic and stats?


How about the lottery? If the Megamillions jackpot is, lets say 500 MM, your changes are not higher to win it, but more is paid out in that drawing than paid in.


From personal experience: this is absolutely true. There is this csgo gambling scene on the internet. It's basically betting with real money but masked as a value of weapon skins. I have made some idiotic decisions in the past regarding these websites and I still regret it a ton. The problem really is that these websites also allow people of any age to gamble with their weapon skins (aka money), and it's fairly easy to buy new skins with actual money.

What's interesting though is that it's easy to observe a ton of gamblers for a long time. And since there is usually also a chat, interacting is also possible. These sites usually have 14 numbers for roulette where 1-7 is red and 8-14 is black, 0 is green which gives 14x your bet. Red and black give you 2x.

If you observe enough gamblers long enough (which I did), you see the same pattern over and over and over again. It goes like this: 1. Gambler starts out with a random amount of money (could be high or low). 2. Gambler wins big (usually like 1-3 times on green) 3. Gambler feels lucky and gives out money to 'passive' beggars* in the chat. ( Sometimes I would feel bad for the gamblers and hint them in the chat that they should cash out, no one ever listened ) 4. Gambler continues and might win some more, or lose some but not all. 5. Gambler has been betting for such a long time that he/she is back at where he/she started. ( Beggars keep begging but gambler says he is down so doesn't give out money right now ) 6. Gambler suddenly wins big on green again (or went all in) and feels like a king again. 7. Now Gambler cashes out (by buying a skin) the money with which they started and continues with what his/her leftovers. 8. Gambler loses the leftover money on the website. 9. Gambler deposits the skin that was previously withdrawn again. 10. Gambler loses everything now and the beggars focus on a different big gambler. 11. Gambler usually comes back within a week or month and loses more money. 12. The cycle continues.

* People, usually kids, that lost their (usually small amount of) money earlier and our now cheering for some big gamblers so these gamblers might send them money on the website.

I personally also lost a (for me) quite big amount of money on these sites over a decent period of time. Later, I was able to sort of stop my addiction and I made a bot which predicted random results (red/black/green) in the chat. It got me like 30 dollars of tips from people that had probably used the bot but the website changed some things so my bot stopped working and I have been too lazy to fix it.

Last thing: I also kept some stats of the roulette because I had to know the timing of the roulette so my bot wouldn't predict if it was already rolling. I added an extra feature for myself so I could see how many times red/black and green were rolled and how many times my bot got the predictions right. Obviously this always ended up in a big loss for my bot (in terms of predictions, I did not bet money with my bot) in the long term.


Blackjack has been a source of success for me though I'm unconventional in my betting strategy which seems to enrage the other players even when I break the dealer consistently.


You've never broken the dealer. Dealer has specific rules in blackjack of when to hit or stand that are completely independent of your cards, betting amount or strategy, emotional attitude, or how good or bad your breath smells.


More likely it's just numbers, right? If 1024 people flip coins ten times in a row, it's expected that one of them gets 10 heads. But he's not a genius, right?

Of course you should always back yourself. So more power to you if you're winning in this way. At least you get to keep playing :)


Derren Brown had an interesting example of this on UK TV a few years ago. It's nothing new, but showing it this way demonstrates how you can get drawn in:

> The System, a Channel 4 special in which Brown shared his "100 percent guaranteed" method for winning on the horses, was first shown on 1 February 2008.

> The show was based around the idea that a system could be developed to "guarantee a winner" of horse races. Cameras followed a member of the public, Khadisha, as Brown anonymously sent her correct predictions of five races in a row, before encouraging her to place as much money as she could on the sixth race.

> After Brown had placed a bet of £4,000 of Khadisha's money on a horse in the final race, he explained how "The System" worked. He had started by contacting 7,776 people and split them into six groups, giving each group a different horse. As each race had taken place 5⁄6 of the people had lost and were dropped from the system. Brown had a different person backing each horse in each race, and one individual, Khadisha, won five times in a row.

https://en.wikipedia.org/wiki/List_of_Derren_Brown_shows#Der...


Horse racing isn’t blackjack, and there are better ways to get an edge. One former colleague had a hobby/obsession. He collected a ton of data and employed a bunch of strategies based on horse, jockey and particularly trainer performance.

One example where he had a good yield was playing shitty races (there are different tiers of horse races, from fancy ones like the Belmont Stakes to down to older or younger horses) in bad turf conditions. He’d look at what horses scratched and which trainers usually scratched and make different bets as the odds would be screwy and in his favor.

He bought toys with his winnings, and his process was making him a decent buck, at least until he retired and we lost touch.

If casino gambling hadn’t gone mainstream, there would be a lot of interesting activity in throughbred racing — now it’s a legacy backwater sport.


Dont they kick you out if you're consistently winning?


Not necessarily. Casinos will kick you out for a particular set of behaviors. Just winning isn't enough.

Playing a minimum bet for a long time, then suddenly increasing to the max near the last half of a shoe is a good way to get a casino to ask you to stop playing blackjack.


Only if you're winning a lot of money. They don't care that a small fish wins a few hundred dollars every now and then.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: