Monty Hall 21 Blackjack

Mimic process of picking at random we use the sample().

replicate() function can be used to repeat a task any number of times.

Monte Carlo simulatin gave a very good approximation.

The Monty Hall problem was mentioned in an episode of the first season of the television drama NUMB3RS, in the 2008 movie 21, in the television Series Brooklyn Nine-Nine in the episode titled the 'Skyfire Chronicle', Season 4 Episode 8, and in the novel The Curious. 3 Doors Math Problem Solved (from the movie 21)This video explains the math problem mentioned in the movie 21. In the movie Kevin Spacey is looking for students to join his blackjack crew, and in his math class he asks this question to see who can think out of the box (aka thinking mathematically?!?!). This video will explain the reasoning of why switching your choose provides a more likely. The Monty Hall problem is a famous, seemingly paradoxical problem in conditional probability and reasoning using Bayes' theorem. Information affects your decision that at first glance seems as though it shouldn't. In the problem, you are on a game show, being asked to choose between three doors. Behind each door, there is either a car or a goat. You choose a door. The host, Monty Hall. 21 = Vegas + MIT kids. Me = born in Vegas (seriously) + going to MIT. My take on the movie, 21: Completely NO spoilers:. Check out rottentomatoes.com reviews here. Check out “General Observations” below. Synopsis: (some spoilers for the first hour of the movie). Ben Campbell (Jim Sturgess), an incredibly brilliant student at MIT who is capable of rattling off sales figures faster than a.

Combinations and Permutations

expand.grid() gives all the combinations of two list

We are going to be using the combination() and permutation() functions from the gtools package.

The permutation functions computes for any list of size n all the different ways we can select R items.

Optionally we can add a vector to this function that defines the range of digits. The code below samples 5 random 7 digit phone numbers out all possible phone numbers.

To compute all possible ways that we can choose 2 cards when the order matters, we simply type the following piece of code.

The above code is the R version of the multiplication rule.

[Pr(Amid B)=frac{Pr(A and B)}{Pr(A)}]

Now, what if the order does not matter? For example, in blackjack, if you get an ace and a face card or a 10, it’s called a natural 21, and you win automatically. If we want to compute the probability of this happening, we want to enumerate the combinations, not permutations, since the order doesn’t matter.

So if we get an A and a king, king and an A, it’s still a 21. We don’t want to count that twice. So notice the difference between the permutations functions, which lists all permutations, and the combination function, where order does not matter. This means that 2, 1 doesn’t appear because 1, 2 already appeared. Similarly, 3, 1 and 3, 2 don’t appear. So to compute the probability of a natural 21 in blackjack, we can do this.

How often do you get aces and facecard

We can also use a Monte Carlo to estimate this probably. In this case, we draw two cards over and over and keep track of how many 21’s we get. We can use the function sample to draw a card with a replacement like this.

The Birthday Problem

Suppose you’re in a classroom with 50 people. If we assume this is a randomly selected group, what is the chance that at least two people have the same birthday? Although it is somewhat advanced, we can actually deduce this mathematically, and we do this later, but now, we’re going to use Monte Carlo simulations. For simplicity, we assumed that nobody was born on February 29th.

Problema De Monty Hall 21 Blackjack

This actually doesn’t change the answer much. All right, first, note that birthdays can be represented as numbers between 1 and 365.

So a sample of 50 random birthdays can be obtained simply using the sample function, like this.

Monty

To check if, in this particular set of 50 people we have at least two with the same birthday, we can use the function duplicated, which returns true whenever an element of a vector has already appeared in that vector.

So here’s an example. If I type duplicated 1, 2, 3, 1, 4, 3, 5,

And in the case that we just generated, we actually do have this happening. We did have two people, at least two people, with the same birthday. We get true. Now, to estimate the probability, we’re going to repeat this experiment. We’re going to run a Monte Carlo simulation over and over again. So what we do is we do it 10,000 times.

We use the replicate function like this.

And when we’re done, we get that the probability of having two people, at least two people, with the same birthday in a group of 50 people is about 0%.

Were you expecting this to be so high? People tend to underestimate these probabilities, so it might be an opportunity for you to bet and make some money off of your friends. To get an intuition as to why this is so high, think of what happens as you get close to 365 people. At this stage, we run out of days, and the probability is 1. In the next video, we’re going to actually compute this probability for different group sizes and see how fast it gets close to 1.

sapply

Say you want to use what you’ve just learned about the birthday problem to bet with friends about two people having the same birthday in a group of people. When are the chances larger than 50%? Larger than 75%? Let’s create a lookup table. We can quickly create a function to compute this for any group. We write the function like this. We’ll call it compute_prob, and we’ll basically make the calculations for the probability of two people having the same birthday.

Well, we use a small Monte Carlo simulation to do it. Now that we’ve done this, we want to compute this function, we want to apply this function to several values of n, let’s say from 1 to 60. Let’s define n as a sequence starting at 1 and ending at 60. Now, we can use a for loop to apply this function to each value in n, but it turns out that for loops are rarely the preferred approach in R.

In general, we try to perform operations on entire vectors. Arithmetic operations, for example, operate on vectors in an element wise fashion. We saw this when we learned about R. So if we type x equals 1 through 10, now X is the vector starting at 1 and ending at 10, and we compute the square root of x, it actually computes the square root for each element.

Equally, if we define y to be 1 through 10, and then multiply x by y, it multiplies each element 1 by 1–
1 times 1, 2 times 2, et cetera.

So there’s really no need for for loops. But not all functions work this way. You can’t just send a vector to any function in R. For example, the function we just wrote does not work element-wise since it’s expecting a scalar, it’s expecting an end.

This piece of code does not do what we want. If we type compute prob and send it the vector n, we will not get what we want. We will get just one number.

What we can do instead is use the function sapply. sapply permits us to perform element-wise operations on any function. Here’s how it works. We’ll define a simple example for the vector 1 through 10. If we want to apply the square roots of each element of x, we can simply type sapply x comma square root, and it’ll apply square root to each element of x.

We don’t need to do this because square root already does that, but we are using it as a simple example. So for our case, we can simply type prob equals sapply n.

n is our vector

and then the function we define compute_prob. And this will assign to each element of prob the probability of two people having the same birthday for that end. And now we can very quickly make a plot. We plot the probability of two people having the same birthday against the size of the group.

Now, let’s compute the exact probabilities rather than use Monte Carlo simulations. The function we just define uses a Monte Carlo simulation, but we can use what we’ve learned about probability theory to compute the exact value. Not only do we get the exact answer using math, but the computations are much faster since we don’t have to generate experiments.

We simply get a number. To make the math simpler for this particular problem, instead of computing the probability of it happening, we’ll compute the probability of it not happening, and then we can use a multiplication rule. Let’s start with the first person. The probability that person 1 has a unique birthday is 1, of course.

Now let’s move on to the second one. The probability that the second person has a unique birthday given that person 1 already took one other day is 364 divided by 365. Then for a person 3, given that the first two people already have unique birthdays, that leaves 363. So now that probability is 363 divided by 365.

If we continue this way and find the chances of all, say, 50 people having unique birthdays, we would multiply 1 times 364 divided by 365, times 363 divided by 365, dot dot dot, all the way to the 50th element.

Here’s the equation: [1timesfrac{364}{365}timesfrac{363}{365}cdotsfrac{365-n+1}{365}]

Now, we can easily write a function that does this. This time we’ll call it exact_prob. It takes n as a argument, and it computes this probability using the simple code. Now we can compute each probably for each n using sapply again, like this.

And if we plot it, we can see that the Monte Carlo simulations were almost exactly right.

They were almost exact approximations of the actual value. Now, notice had it not been possible to compute the exact probabilities, something that sometimes happens, we would have still been able to accurately estimate the probabilities using Monte Carlo.

How many Monte Carlo experiments are enough?

In practice, we won’t know what the answer is, so we don’t know if our Monte Carlo estimate is accurate. We know that the larger the number of experiments, we’ve been using the letter B to represent that, the better the approximation. But how big do we need it to be? This is actually a challenging question, and answering it often requires advanced theoretical statistics training. One practical approach we will describe here is to check for the stability of the estimate.

Here’s an example with the birthday problem. We’re going to use n <- 22. There’s 22 people. So we’re going to run a simulation where we compute or estimate the probability of two people having a certain birthday using different sizes of the Monte Carlo simulations. So the value of B going to go from 10, to 20, to 40, to 100, et cetera. We compute the simulation, and now we look at the values that we get for each simulation.

Remember, each simulation has a different B, a different number of experiments. When we see this graph, we can see that it’s wiggling up and down.

That’s because the estimate is not stable yet. It’s not such a great estimate. But as B gets bigger and bigger, eventually it starts to stabilize. And that’s when we start getting a feeling for the fact that now perhaps we have a large enough number of experiments.

The Addition Rule

The additional rule tells us that the probability of A or B, we’re going to have to make this calculation now, because you can get to 21 in two ways. You can get either a face card and then an ace. Or you can get an ace and then a face card. The additional rule tells us the probability of A or B is the probably of A plus the probably B minus the probability of A and B.

To understand why this makes sense, think of a Venn diagram. If we’re computing the probability of this whole thing happening, A or B, we can add the blue circle plus the pink circle, and then subtract the middle because we have added it twice by adding the blue plus the pink.

So now let’s apply it to the natural 21. In the case of natural 21, the intersection is empty. Since both hands can’t happen, you can’t have both an ace and then a face card, and then at the same time have a face card and then an ace. Those two things can’t happen at the same time. So this will be a very easy application of the addition rule. The probably of an ace followed by a face card we know is (frac{1}{13}timesfrac{16}{51}). And the probability of a face card followed by an ace is (frac{16}{52}timesfrac{4}{51}). These are actually the same, which makes sense to the symmetry. These two values are actually the same. In any case, we get the same result that we got before for the natural 21, which is about 0.05.

The Monty Hall Problem

We’re going to look at one last example from the discrete probability. It’s the Monty Hall problem. In the 1970s, there was a game show called “Let’s Make a Deal”. Monty Hall was the host– this is where the name of the problem comes from. At some point in the game, contestants were asked to pick one of three doors. Behind one door, there was a prize. The other two had a goat behind them. And this basically meant that you lost.

If the contestant did not pick the prize door on his or her first try, Monty Hall would open one of the two remaining doors and show the contestant that there was no prize behind that door. So you’re left with two doors, the one you picked and one door that you do not know what’s behind it. So then Monty Hall would ask, do you want to switch doors? What would you do? We can use probability to show that if you stick to the original door, your chances of winning a car or whatever big prize is 1 in 3. But if you switch, your chances double to 2 in 3. This seems counterintuitive. Many people incorrectly think both chances are 1 in 2, since there’s only two doors left and there’s a prize behind one of them. You can find details, explanations– we’re going to provide links of the mathematics of how you can calculate that this is, in fact, wrong, that you have a higher chance if you switch. But here, we’re going to use a Monte Carlo simulation to show you that this is the case. And this will help you understand how it all works. Note that the code we’re going to show you is longer than it needs to be, but we’re using it as an illustration to help you understand the logic behind what actually happens here. So let’s start by creating a simulation that imitates the strategy of sticking to the same door.

Let’s go through the code. We’re going to do 10,000 experiments. So we’re going to do this over and over 10,000 times. First thing we do is we assign the prize to a door. So the prize is going to be in one of the three doors that we have created. Then that’s going to be in prize door. Prize door contains the number of the door with the prize behind it. Then we’re going to imitate your pick by taking a random sample of these three doors. Now, in the next step, we’re going to decide which door you’re shown. You’re going to be shown not your door and not the door with a prize. You’re going to be shown the other one. You stick to your door. That’s what you stick to. Nothing changed. All this that we did right above doesn’t matter, because you’re sticking to your door. So now we do this over and over again, and at the end, we ask is the door you chose, the one you stuck to, is that the prize door? How often does this happen? We know it’s going to be a 1/3, because none of this procedure changed anything. You started picking one out of three, nothing changed. And now, you are asked, is the one I picked the door? If we run the simulation, we actually see it happening. We ran it 10,000 times and the probability of winning was 0.3357, about 1 in 3.

Exercise 1. The Cavs and the Warriors

Two teams, say the Cavs and the Warriors, are playing a seven game championship series. The first to win four games wins the series. The teams are equally good, so they each have a 50-50 chance of winning each game.

If the Cavs lose the first game, what is the probability that they win the series?

  • Assign the number of remaining games to the variable n.
  • Use the list function to create a list of game outcomes, where 0 indicates a loss for the Cavs and 1 indicates a win for the Cavs. Assign this value to the variable l.
  • Use the expand.grid function to create a data frame containing all the possibilities for outcomes of the remaining games.
  • Use the rep function within the expand.grid function to indicate the number of columns the results data frame should contain.
  • Use the rowSums function to identify which combinations of game outcomes result in the Cavs winning the number of games necessary to win the series.
  • Use the mean function to calculate the proportion of outcomes that result in the Cavs winning the series.

Exercise 2. The Cavs and the Warriors - Monte Carlo

Confirm the results of the previous question with a Monte Carlo simulation to estimate the probability of the Cavs winning the series after losing the first game.

  • Use the replicate function to replicate the sample code for B <- 10000 simulations.
  • Use the sample function to simulate a series of 6 games with random, independent outcomes of either a loss for the Cavs (0) or a win for the Cavs (1).
  • Use the sum function to indicate which of the simulated series contained at least 4 wins for the Cavs.
  • Use the mean function to find the proportion of simulations in which the Cavs win at least 4 of the remaining games.

Exercise 3. A and B play a series - part 1

Two teams, (A) and (B), are playing a seven series game series. Team (A) is better than team (B) and has a (p > 0.5) chance of winning each game.

  • Use the function sapply to compute the probability, call it Pr of winning for p <- seq(0.5, 0.95, 0.025).
  • Then plot the result plot(p, prob).

Exercise 4. A and B play a series - part 2

Repeat the previous exercise, but now keep the probability that team (A) wins fixed at p <- 0.75 and compute the probability for different series lengths. For example, wins in best of 1 game, 3 games, 5 games, and so on through a series that lasts 25 games.

Monty Hall 21 Blackjack
  • Use the seq function to generate a list of odd numbers ranging from 1 to 25.
  • Use the function sapply to compute the probability, call it Pr, of winning during series of different lengths.
  • Then plot the result plot(p, Pr).
Problema de monty hall 21 blackjack

R Core Team. 2018. R: A Language and Environment for Statistical Computing. Vienna, Austria: R Foundation for Statistical Computing. https://www.R-project.org/.

Everything starts with an idea and it’s that idea that grows into the reality people get to witness. The stronger it gets, the better the chances of getting the results you want. There is a movie that portrays this very clearly. Before we talk of the movie, let us talk about the idea behind that movie.

Although it ended up on television as a movie, 21 was actually a story. The story talks about a group of students and ex-students of the Massachusetts Institute of Technology, Harvard University, and other major colleges. They were known as the “MIT Blackjack Team.” The team developed a number of sophisticated techniques and strategies to beat casinos. The legacy continued with its successors that successfully operated from 1979 into the beginning of the 21st century.

The Movie is also based on Ben Mezrich’s bestselling gambling book titled “Bringing Down the House.” There are still debates if the movie is a true-life story or not. As for the techniques, we will discuss more about it below. Please read carefully.

The MIT Blackjack Team

As earlier stated, the team was formed by a group of ex-students but not only. There were also students and professors on board. It started in early 1979 when six MIT students and residents of the Burton-Conner House at MIT taught themselves the technique of card-counting. They traveled to Atlantic City during the spring break and made a fortune from gambling. The group split up after they graduated as most of them went their separate ways. Indeed, some of them went on to pursue careers in their courses of study and never gambled again. A number of them were still interested in the game of cards and stayed in Cambridge, Massachusetts.

Masaar and Jonathan were two of the card-counting students that stayed back. While remaining in Cambridge, Massachusetts, they put out a notice for a card-counting course. In November 1979, Dave who was a professional blackjack player contacted Masaar. This was after he saw a notice for the blackjack course. Dave told Masaar about forming a new gambling group. The group will to go to Atlantic City to take advantage of the New Jersey Casino Control Commission’s recent ruling. You should know that this ruling made it illegal for the casinos in the Atlantic City to ban card counters.

Monty Hall 21 Blackjack

Instead of banning card counting, the commission’s ruling made casinos take countermeasures like using more decks of cards or shuffling the card earlier than normal. They also impose rules that nullify the advantage that players using card counting might have gained.

How the Team Was Formed and Evolved

Dave and Masaar were able to recruit more MIT students. The group consisted of four players, a professional gambler, and an investor. They were able to raise the sum of $5,000 that mainly helped them move to Atlantic City in late December. By May 1989, they had already made 400% of their capital.

Although they were a team, they were not that strategic. They were more like a group of individual sharing capital. It’s safe to say that they lacked strategy, consistency, control and other qualities of a standard team. In May 1980, Masaar met with Kaplan (who was a professional blackjack). Kaplan is a Harvard MBA graduate that ran a successful blackjack team in Vegas. He formed a team of blackjack players using his own research and statistical analysis of the game when he moved to Las Vegas.

Kaplan’s team had bigger plans to explore Europe and the world at large. However, he could not cope with managing a team who wanted to explore the world and his studies. So, he had to part ways with his team. Masaar sold the idea of ​​working with his team to Kaplan. Without much thought, Kaplan bought the deal as he had hopes of training and managing a local team after losing his old team. After watching Masaars’s team, Kaplan informed him the need to improve on their strategies and team management.

Real Life Achievements and Eventual Downfall

Initially, the team did not welcome the idea of ​​working with a new strategy or with a new set of rules. Giving information such as cash in and cash out, tracking of casino play and strict training did go down well with them initially. However, it was not long before increase in success rates won them over. The new MIT Blackjacks was formed on the 1st of August 1980. They were able to raise the sum of $89,000 from both the player themselves and external investors.

The team grew bigger, recruiting more than 35 players in 1984 with as much as $350,000 in capital. It was not long before casinos began to take note of the various MIT blackjack team members. In lieu of that, the MIT signed a great number of partnerships from 1980–1989 and over 70 people played a part in the team with various capacities. In 1992, the leaders of the MIT team trained some players and made the most of the opening of Foxwoods Casino in Connecticut. They formed a partnership in 1992 called Strategic Investments to fund the new team.

While they made money from casinos, they also made enemies. Kaplan was always followed whenever he was spotted in a casino as casinos sought to trace and identify members of the MIT blackjack team. Investigations began and investigators discovered that members of the MIT blackjack team had addresses in around Cambridge and had connections to MIT. It wasn’t long till the investigators were able to identify and ban the major players of the MIT blackjack team.

With its major players banned from casinos, the MIT blackjack team knew it was a matter of time before their time was up. They were now banned from most casinos. They were also excluded from other lucrative investment opportunities that were opening at the end of the recession.

“21” The Movie Review

“21” The Movie was a movie released in 2008 and based on the story of the MIT Blackjack Team. The movie features Ben, mathematics major at MIT that gained admission into Harvard Medical School but could not afford the $300,000 tuition. It also features Micky Rosa, a professor at MIT that challenged Ben with the Monty Hall Problem. To his great surprise Ben, solved it successfully.

Micky then invites Ben to join his blackjack team that consists of other students like Choi, Fisher, Jill, and Kianna. In a short period, Ben won the team over with his skills, and a member of the team becomes jealous of him. Ben becomes arrogant, ignores orders, and causes the team to lose money.

Ben and Micky turn on each other. Micky sets Ben up, uses his influences and connections to punish him. In return, Ben sets Micky up, but they both make up in the end. The storyline is quite complex. It involved jealousy, anger, and betrayal. Despite its complicated nature, the movie was a box-office success.

Il Paradosso Di Monty Hall ( 21 Blackjack)

Mastering Blackjack Card Counting

Card-counting is one of the major tactics the MIT Blackjack Team used to win at casino card games. Although they used other techniques such as shuffle tracking and hole carding, card counting was their major strategy. You might wonder, what is card-counting?

Well, card counting is a casino card game strategy used primarily in the blackjack family of casino games to determine whether the next hand is likely to favor the player or to the dealer. The goal of a card-counting system is to assign point values ​​to each card that roughly correlate to the card’s “effect of removal” or EOR. This enables the player to gage the house advantage based on the composition of cards still to be dealt.

The player can gage the effect of removal for all cards dealt and assess the current house advantage of a game based on the cards that are left. The procedure is simple. You assign negative values ​​to lower cards and positive values ​​to higher cards, always keeping track of the value of cards. Add the values ​​you assign to the cards to determine the value of the cards on the deck. Increase your bet if the count is negative and lower it if it’s positive.

Does Card Counting work when Playing Online?

For this part I had to seek the help of Hunter Wilson which is a senior casino games reviewer at casimoose.ca for his expertise on this matter. You can follow Hunter over here.

Just like other games of casinos like slots, blackjacks can also be played in online casinos. You can always visit casimoose.ca to get the list of trusted online casinos. You already know that Card-counting work with regular casinos. However, basic card-counting will hardly work with online casinos. This is because online casinos use blackjack software that shuffles the deck cards after it deals each hand. It is worthy of note that even offline casinos now use multiple decks to reduce the advantage of card-counting.

Card-counting is not illegal unless players are using a calculating device. No one will arrest you if you are using your math skills. However, it is important to note that the players in the movie and book used group play as a strategy. Although no one stops you from playing as a group, it is illegal to give signsto one another when playing at a casino. Group play may also not work at most online casinos. You can always visit casimoose.ca to get a list of casinos where you can play and practice your card-counting skills.

Comments are closed.