[HN Gopher] Monte Carlo methods
       ___________________________________________________________________
        
       Monte Carlo methods
        
       Author : redbell
       Score  : 210 points
       Date   : 2023-05-13 12:15 UTC (1 days ago)
        
 (HTM) web link (easylang.dev)
 (TXT) w3m dump (easylang.dev)
        
       | tonetheman wrote:
       | [dead]
        
       | johnfarrelldev wrote:
       | I haven't completed or deployed it yet but I wrote a C# API to
       | calculate your chance of winning a hand of poker based on all
       | known cards at the table.
       | 
       | All unknown cards are randomly assigned and it just loops a
       | bunch, reasonably easy to implement and actually is reasonably
       | fast.
       | 
       | https://github.com/JohnFarrellDev/PokerMonteCarloAPI/
       | 
       | With the amount of possible outcomes Bayesian statistics just
       | didn't seem reasonable to implement.
       | 
       | Goes without saying this tool is still fairly basic, it shouldn't
       | be used to inform how much to bet or when to fold as it doesn't
       | take into account information such as how much your opponents are
       | betting.
        
         | gmi01 wrote:
         | I wrote a Haskell version that includes two components:
         | 
         | A very efficient function to rank a set of Texas Hold'em hands.
         | 
         | A Monte Carlo situation that gives you the probability of
         | winning each hand from any known amount of information.
         | 
         | It is available here: https://github.com/ghais/poker
        
           | bionsystem wrote:
           | Not sure if you guys are aware but there are solvers existing
           | (most of which are proprietary) that actually give optimal
           | strategies with every possible hands given a betting pattern.
           | They are used extensively as study tools by professional
           | players.
        
             | SnowHill9902 wrote:
             | Can you link to some projects? Ideally also Haskell or also
             | functional?
        
               | bionsystem wrote:
               | I use GTO+ which is proprietary.
               | 
               | I just tried this one which works like a charm (just run
               | the exe from the zip in github releases ; even comes pre-
               | loaded with a wide amount of preflop ranges, which seem
               | to come from a previous solve) :
               | https://github.com/bupticybee/TexasSolver
               | 
               | Searching with "poker solver haskell" only seem to show
               | very immature projects.
        
       | IngoBlechschmid wrote:
       | Very nicely polished! Thank you for sharing!
       | 
       | For the purposes of teaching Python, I once created something
       | similar---but without the explanations:
       | 
       | https://www.speicherleck.de/iblech/zufall-im-browser/index.e...
        
       | opensourceac wrote:
       | Just finished embedding a Python component on my site -
       | https://www.actuarialopensource.org/book/welcome.
       | 
       | Uses react-py. Some effort required to implement tabs and manage
       | lifecycle of Pyodide for separate editors.
        
       | chkas wrote:
       | Hi. Author here. It is shown here on different in the browser
       | executable and editable programs with Monte Carlo methods that
       | one cannot win at roulette if one plays many times. Many know
       | this, but many do not, and therefore this can be helpful. After
       | all, there are more than a few who lose their financial existence
       | in the casino.
        
         | iamcreasy wrote:
         | Thank you for writing. Very clearly explained.
         | 
         | Can you explain how do you derive this?
         | 
         | print 10 * 10000 * (18 / 37 - 19 / 37)
        
           | alexeldeib wrote:
           | Per round expected value of +/- 10, times 10k rounds, 18/37
           | lose probability 19/37 win probability.
        
           | Jtsummers wrote:
           | That's an expected value calculation.
           | 
           | It breaks down into three parts:
           | 
           | 1. The wager per round ($10). This is, in the game being
           | simulated, the amount won or lost based on the game's
           | outcome.
           | 
           | 2. The number of rounds (10000).
           | 
           | 3. The probability of winning minus probability of losing.
           | 
           | Forgetting the number of rounds for a moment, the way to
           | calculate the expected value of a single wager like this is:
           | E[X] = x1*p1 + x2*p2 + ... + xn*pn
           | 
           | Where each `xN` is the value (amount won or amount lost since
           | we're talking about wagers) of an event and `pN` is the
           | probability of that event. In this case there is an 18/37
           | chance of winning and 19/37 chance of losing. The value of
           | winning is +10 and the cost of losing is -10. So the expected
           | value of a $10 wager ends up being:                 10 *
           | 18/37 - 10 * 19/37
           | 
           | Multiply that by 10,000 for the number of rounds played and
           | you get the expected value of a series of games.
        
             | sokoloff wrote:
             | Note that's the calculation for a European (single green 0)
             | wheel, not the American (green 0 and green 00) wheel, in
             | which you'd replace with +18/38 (or 9/19) and -20/38 (or
             | 10/19).
             | 
             | Yes, the American version is twice as bad for the player,
             | but it doesn't matter; people are still plenty eager to
             | play it...
        
       | [deleted]
        
       | afterburner wrote:
       | On the following blackjack page (link at the bottom of the page),
       | the phrase "Buy up to 17" can be misleading.
       | 
       | The author means "if your total is 17 or less, get another card".
       | But it can easily be interpreted as "keep asking for more cards
       | until you have 17 or more"; almost the same, but different.
        
       | winddude wrote:
       | Fun! and just as "21" taught us card counting is always the
       | answer.
        
       | abecedarius wrote:
       | I love how lightweight and interactive this is.
       | 
       | Related: Norvig's runnable intro probability notebooks at
       | https://github.com/norvig/pytudes#pytudes-index-of-jupyter-i...
        
       | uoaei wrote:
       | A closely related idea is _Approximate Bayesian Computation_ :
       | https://www.sumsar.net/blog/2014/10/tiny-data-and-the-socks-...
        
       | listenallyall wrote:
       | Discussed multiple times before:
       | 
       | https://news.ycombinator.com/item?id=20359100
       | https://news.ycombinator.com/item?id=29217539
       | https://news.ycombinator.com/item?id=35927627
        
       | tommica wrote:
       | This is so cool - simple and educative!
        
       | giantg2 wrote:
       | Very cool. At first I thought this would be about project
       | management using Monte Carlo for target dates.
        
       | kenniskrag wrote:
       | What's about online poker. Is there also a bank advantage if you
       | play perfectly? Is it allowed?
        
         | zer0tonin wrote:
         | https://en.wikipedia.org/wiki/Rake_(poker)
        
         | travisjungroth wrote:
         | Poker is quite different. In roulette, the house advantage is
         | probabilistic. As the linked page shows, that advantage is
         | overwhelmingly likely to materialize, and rather quickly at
         | that. But the probability that you play a million rounds of
         | roulette and end up ahead isn't exactly zero, just such a
         | ridiculously small number you might as well call it zero for
         | real life purposes.
         | 
         | Casinos make money on poker play differently, and in a few
         | ways. The simplest is "rake". They take a fixed percentage of
         | every pot. This is different because it's not probabilistic.
         | The casino isn't gambling its own money. It's just a tax.
         | 
         | Money only comes in from players. So the EV of all players is
         | negative, because a little is flowing out to the casino every
         | hand. The chance players as a whole end up ahead isn't near
         | zero, it is zero.
         | 
         | If everyone was playing theoretically perfect poker every hand,
         | all individual players EV are also negative. But, no one is
         | playing perfect all the time. So you can get ahead because
         | you're not beating the odds. You're beating other players.
        
       | adancalderon wrote:
       | We can do math integration and solve radiation transport problems
       | with Monte Carlo.
        
         | webdoodle wrote:
         | Yep, several particle accelerator studies use it to model
         | neutrino's.
        
         | acidburnNSA wrote:
         | It was actually invented for this.
         | 
         | Open source radiation transport Monte Carlo code here if you'd
         | like to play around:
         | 
         | https://github.com/openmc-dev/openmc
        
           | eodhosb wrote:
           | and ENIAC's first programs were Monte Carlo simulations.
        
         | CyberDildonics wrote:
         | Any integral you can sample can be solved with monte carlo
         | methods. This doesn't really have anything to do with the link.
        
           | spookystats wrote:
           | Actually it does, because MC integration works due to the law
           | of large numbers - exactly what is presented in the article.
        
             | CyberDildonics wrote:
             | Right, that's what is in the article, but just naming a
             | random arbitrary use doesn't make any sense.
        
       ___________________________________________________________________
       (page generated 2023-05-14 23:00 UTC)