Bayesian Modeling with PyMC: Dirichlet and a Custom Stochastic

There was a question asked on Reddit’s r/statistics by user nomm_ in this post. It sounded like the perfect problem for some Bayesian modeling, so I dusted off the PyMC Python library to tackle it. This will also serve, I hope, as a guide to others who are trying to do things like custom stochastics in PyMC that are also observed values.

The question involves estimating the probabilities of selecting a particular action several times in a row (the action involved upgrading items in a video game). There are nodes that need to be linked, and the actions decide how many to link. Several actions can take place for each result, and the actions change likelihood based on the previous actions. Let’s see how to tackle this!

Continue reading →

Progressive Betting Strategies Analysis with Markov Chains

If you are a fan of statistics and probability, then you might have a certain affinity for various games of chance. It can be quite fun to, for example, figure out card counting strategies in Blackjack with simulation. It might also be interesting to try to use some machine learning on the basic strategy tables to figure out smaller, easier to learn sub-sets (something that I want to try at some point).

Hopefully you are also aware of the Gambler’s Fallacy. If you have (or think you have) a problem with gambling, don’t be afraid to seek help! Also, never EVER gamble with money that you can’t afford to lose. Always set aside a given amount of money that you are 100% fine with losing all of (because that will happen).

There are excellent sites out there (like Wizard Of Odds) that give excellent information on probabilities and house edges (notice how none are in our favor!). There are also plenty of discussion of strategies (usually about how bad they are). What I was curious about was whether or not some betting strategies were able to increase the probability of making a set profit (and then stopping). Most people don’t go to the casino very often (if at all), so I wanted to find out about short-term behaviors of these strategies, rather than the obvious long-term failure.

Using Markov Chain analysis and Monte Carlo simulation (in the next post), I’m going to examine some betting strategies. The obvious conclusion is “you will still lose everything in the long run”, but there are some interesting twists along the way. I’ve included some code so you can set up your own analyses, too!

Continue reading →