Monty Hall Dilemma Simulation

Published on Sunday, April 16, 2017 in , , , , , ,

Quantockgoblin's 6-person demonstration of the Monty Hall DilemmaBlame Marilyn vos Savant. Back in 1990, Craig F. Whitaker of Columbia, Maryland wrote to her with a probability puzzle, and found he'd kicked up a hornet's nest! He asked, “Suppose you’re on a game show, and you’re given the choice of three doors. Behind one door is a car, behind the others, goats. You pick a door, say #1, and the host, who knows what’s behind the doors, opens another door, say #3, which has a goat. He says to you, 'Do you want to pick door #2?' Is it to your advantage to switch your choice of doors?”

Marilyn replied that, if you switch, your odds of winning the car are ⅔, and if you don't switch, your odds are only ⅓. It was difficult for many to believe. Even subsequent discussions about these probabilities, such as the Scam School episode on the Monty Hall Dilemma, find that the belief in a 50-50 chance prevails.

Despite all the numerous ways there are to explain it, practical demonstration if often the most effective way to see that the ⅔ odds of winning is correct.

Oxford Mathematics Professor Marcus Du Sautoy shows the effectiveness of practical demonstration to English comedian Alan Davies when it comes to the Monty Hall Dilemma:

While the practical demonstration in this video is effective, it's a little surprising that the switch approach won 4 times as often as it lost. This is one of the classic problems with using a small sample size (such as playing this game only 20 times). Over at Epanechnikov's blog entry on the Monty Hall Dilemma, he features a graph of repeated simulations that shows the problem with just 20 runs:

The probabilities don't even really start settling down to the calculations until about 300 trials have been run! To help see the true odds, why not use a computer to run thousands of simulations very quickly? Inspired by the spreadsheet approach used by Presh Talwalkar to simulate trials for a different probability puzzle, I decided to do the same for the Monty Hall Dilemma.

How do you set it up? The first column states the door which holds the car, and this is generated as a random integer ranging from 1 to 3. The second column states the door chosen by the player, and this is also generated as a random integer ranging from 1 to 3.

The next column is a little trickier. It's going to hold the door which is shown by the host, but there are restrictions on which door can be shown by the host, so we can't just randomly generate a number. The host will only show a door that was NOT chosen by the player and that the host knows will contain a goat. How do we communicate these restrictions to a spreadsheet? There are 2 cases to consider here. First, what happens when the door which contains the car DOESN'T match the door chosen by the player, such as when the car is behind door #1 and the player initially chooses door #2? In this case, the host can only show door #3. In fact, since 1 + 2 + 3 = 6, we can simply subtract the number of the door with the car and the number of the door chosen by the player from 6 to get the number of the door shown by the host.

That only works when the door chosen by the player and the door holding the car are different. What do we do when those two doors are the same? If the player chooses door #1 and the car is behind door #1, we can have the computer choose randomly between door #2 and door #3. A similar approach is used for the other 2 doors, of course. The final spreadsheet entry reads this way:

Translated into English, that says, “If the first two columns (the door hiding the car and the door chosen by the player) are the same, then choose a number, either 1 or 2, at random. If 1 is chosen, look at the number of the door hiding the car, and choose that item from the following list of numbers: 3, 1, 2 (So, if door #1 is hiding the car, choose the 1st number, 3, and so on). If 2 is chosen, look at the number of the door hiding the car, and choose that item from the following list of numbers: 2, 1, 3 (So, if door #1 is hiding the car, choose the 1st number, 2, and so on). Finally, if the first two columns don't match, just take the number 6, subtract the number of the door hiding the car, then subtract the number of the door chosen by the player, and use that as number of the door shown by the host.”

Fortunately, the final 2 columns are easier. The 4th column shows either a 1 if the players wins without switching, and a 0 if the player loses by not switching. Since the player only wins without switching when they chose the door containing the car initially, this column is only a 1 if the first 2 columns have the same number. For the opposite case, the 5th column shows either a 1 if the players wins by switching, and a 0 if the player loses by switching. In this case, a 1 is displayed only if the first 2 columns have different numbers.

Once we've got those columns set up as described above, we can copy them for as many trials as desired! I've set this up on Google Sheets to run 10,000 trials. The results are reported at the top, and take a few seconds to run (keep an eye on the progress bar in the upper right which will disappear when all the calculations are finished). For the "Player stays & wins" percentage calculation, the spreadsheet totals up all the 1s and 0s in the 4th column and divides by 10,000. For the "Player switches & wins" percentage calculation, the spreadsheet does the same thing for the 1s and 0s in the 5th column.

What do you think? Are 10,000 trials enough to convince you of the proper odds of the Monty Hall dilemma?


Out of Control

Published on Sunday, April 09, 2017 in , , , , ,

Scam School logoWould you believe tha another of my contributions has made it on to Scam School again? It was 2 other recent Scam School submissions that spurred me to restart Grey Matters, so it's looking like that was the right move.

Even if you've seen this week's Scam School episode, you may want to take a look at this post, as I'm going to give a few tips that may make this routine easier to learn.

Let's get started right away with this week's Scam School episode with a trick I dubbed “Out of Control”!

Quick side note: On one hand, I love being promoted as "the genius". On the other hand, I can't help but think of “genius” in this context.

This trick is actually a combination of two idea from two men who have far more a right to be called genius than me. The dealing procedure comes straight from Jim Steinmeyer's routine Remote Control, as published in Invocation #43 and the May 1993 issue of MAGIC Magazine. If you check those sources out, you'll see that not much has changed, as the original involves spelling the word C-O-L-O-R, and using the 9th card.

I combined this trick with a technique from Simon Aronson's “Try The Impossible” called Simon's Flash Speller. It's this part that may help make it easier to work out what you need to do. First, you'll need to quickly work out how many letters are in the name of the turned-up card. Here's the starting point:

  • For clubs, remember: 11 letters
  • For hearts or spades, remember: 12 letters
  • For diamonds, remember: 14 letters
Remember, that's just a starting point. From here, you may need to adjust the amount of letters, but only by adding or subtracting 1! What happens with which amount of letters?
  • If the value spells with 4 letters (four, five, nine, jack or king): Don't make any adjustment to the number of letters.
  • If the value spells with 3 letters (ace, two, six, or ten): Subtract 1 from the number of letters.
  • If the value spells with 5 letters (three, seven, eight or queen): Add 1 to the number of letters.
Once you've made that adjustment, you now know how many letters are in the card's full name! It seems difficult at first, but gets much easier with practice. 5 of Hearts? Hearts is 12 letters, and no adjustment needed, as F-I-V-E spells with 4 letters. 7 of Diamonds? Diamonds is 14, plus 1 for a 5-letter value (S-E-V-E-N), that's 15 letters. 10 of Clubs? Clubs is 11 letters, minus 1 for a 3-letter value (T-E-N), that's 10 letters.

From here, there are 6 ways the trick can go, so you have to quickly recall which out to use. There's really only 2 substantially different outs, with 12 and 13 letters. All the other outs are just modifications of those two. First, how do you handle cards whose names spell with 12 and 13 letters?
  • For 12 letters: Spell the name, and take the top card of those still in your hand.
  • For 13 letters: Spell the name, and take the last card that was dealt off.
How do you adjust this process for 14 or 15 letters? It's simple, you spell the value and suit without spelling O-F in the middle. This reduces any 14-letter card names to 12 letters and reduces any 15-letter card names to 13 letters. If you're keeping track, we've already covered 4 of the 6 possible outs!

The last two possibilities involve 10- and 11-letter card names:
  • For 10 letters: Spell T-H-E before the card name (such as T-H-E-A-C-E-O-F-C-L-U-B-S), resulting in 13 letters.
  • For 11 letters: Deal the turned up card aside, and spell its name with the next 11 cards, resulting in 12 cards being used.
Between determining the number of letter and which out to use, it can all seems a little confusing. However, like any good magic trick, it does take practice. The smoothness with which you can make this trick flow is the key to its deceptiveness.

For those who are wondering how the math of this trick works, the first deal is obvious. The selected card starts at the 10th position, of which 4 are dealt off, so it winds up at the 6th position. It's the second deal that is highly counterintuitive. In fact, watch the video starting at the 3:30 mark, and when they realize that the card winds up as the 13th card despite the two different spellings, Matt (the gentleman with the long beard, who has created his own original magic, as well!) comments, “My brain's breaking a little bit now!”

To explain, imagine you're doing this trick with cards numbered from 1 to 18, in order, with card 1 on top. If you deal 7 cards, as in the R-E-D-S-U-I-T possibility, as calculated on Wolfram|Alpha, you see that the 6th card from the top winds up being the 6th card from the bottom. If you deal 9 cards, as in the B-L-A-C-K-S-U-I-T possibility, Wolfram|Alpha tells us that, once again, the 6th card from the top winds up as the 6th card from the bottom.

It only seems like the different amount of letters should change the location of the card, but it actually has the same effect, as long as you deal past the selected card! If you have any further questions about this routine, or anything else on this blog, let me know in the comments below.


Leapfrog Division V: I've Been Schooled!

Published on Sunday, April 02, 2017 in , ,

x divided by y fraction iconA little over 4 years ago, I wrote a post inspired by Alexander Craig Aitken's approach to dividing by numbers ending in 9, called Leapfrog Division. It's a remarkably fun and simple technique, so if you haven't already checked it out for yourself, give it a read.

I wrote 3 more posts in that series. Leapfrog Division II dealt with dividing by numbers ending in 1. My last 2 posts before this year were Leapfrog Division III, which dealt with dividing by numbers ending in 8, and Leapfrog Division IV, which dealt with dividing by numbers ending in 2.

These were fine, but the latter 3 posts employed rules that became increasingly cumbersome, and were tricky to apply quickly and without error. Recently, however, I learned a far simpler approach that makes these later posts much simpler!

Let's start with credit where credit is due. The thanks should go to Saurabh G over at Hubpages. He had a post at Owlcation titled Divide Numbers Easily Using Vedic Mathematics: Fast and Easy Division Techniques. Towards the end of the post, there's a section with the heading, “How Do You Use Vedic Division When the Divisor Is More Than One Digit?”. The approach taught with numbers ending in 9 is demonstrated a little differently, but is mathematically identical to the original Leapfrog Division post.

The next section, “Multi-Digit Divisor Ending in 8 Example,” is what really struck me the most. He teaches an almost identical approach, and casually mentions that the quotient needs to be doubled before adding the remainder to the 10s place. Click on that link, read through the example, and then compare that approach to what I taught in Leapfrog Division III. I do mention a doubling idea, but the rules I taught are far more complex.

Using Saurabh G's vedic math approach, here's how his example (73 ÷ 138) would look written in the style of the Leapfrog Division posts. We start with the idea that 14 won't go into 7.3, so we start with a 0 and decimal point at the beginning of the answer, and work from there:

  • 73 ÷ 14 = 5 (remainder 3)
    (Double the 5 to get 10, add the 3 in the 10s place to get 40)
  • 40 ÷ 14 = 2 (remainder 12)
    (Double the 2 to get 4, add the 12 in the 10s place to get 124)
  • 124 ÷ 14 = 8 (remainder 12)
    (Double the 8 to get 16, add the 12 in the 10s place to get 136)
  • 136 ÷ 14 = 9 (remainder 10)
    (Double the 9 to get 18, add the 10 in the 10s place to get 118)
  • 118 ÷ 14 = 8 (remainder 6)
    (Double the 8 to get 16, add the 6 in the 10s place to get 76, and continue on from here, if desired....)

If you wrote down the quotients (the number in bold above) as you went, you'd have written down 0.52898 at this point, which is correct as far as we've gone.

Just to round things out, he includes a chart showing how to adapt this approach for numbers ending in 9 all the way down to 1! Think about that: It took me 3 years and 4 posts to cover numbers ending with 4 different digits, and increasingly difficult rules. Someone else comes along, teaches 2 examples in 1 post, and leaves his readers confident they can handle 9 different digits.

I tip my hat to you, Saurabh G! Thank you for sharing this approach, and giving me and my readers a simpler and more effective mental division tool.


3 Planets and a Rational War

Published on Friday, March 17, 2017 in , , ,

Still of Clint Eastwood from The Good, The Bad and The UglyDuels are a classic staple of westerns, but it took Sergio Leone's 1966 film “The Good, The Bad and The Ugly” to immortalize the truel (neologism for a three-way duel) in the popular mind!

Back in 1975, a high school teacher named Walter Koetke took the truel into outer space in a puzzle from the May/June 1975 issue of Creative Computing. I first ran across it in the 1980s, in The Best of Creative Computing.

This puzzle concerned 3 planets, Mutab, Neda and Sogal, who have agreed to an unusually rational war. Each planet would fire planet-destroying missiles at one another in turns, with the order of the truns being determined by random drawing. The rocket launching continues in order until only 1 planet remains. However, each planet has different capabilities. Mutab is the most advanced, and when fired at a target, have a 100% chance of destroying that target. Neda is the next most advanced, but their missiles only have an 80% chance of destroying their target. Sogal is the least advanced of the three, with missiles that only have a 50% chance of destroying their target. The puzzle is this: What are each planet's chances of surviving a war?

Even when I first ran across the problem as a teen, I remember thinking how difficult this problem must be. I realized that any calculations between the less-than=100% chances of battles between Neda and Sogal would be difficult to deal with, as they could go on for several turns, much like encountering long heads-only or tails-only runs in coin-flipping. The problem did stick in the back of my mind, though, as I thought it would be interesting to analyze when I knew more about math.

That day arrived when I first learned about Markov chains. If you're already familiar with Markov chains, you're ready for my solution. I've set up a site that takes you through the solution step-by-step here. Start by clicking the “Click to work out 2-world battles” button, and then read through the logic and tables until you get to the next button. Keep proceeding that way all the way to the end. It's written using Bootstrap, so it should be viewable using any size screen (the larger tables can be swiped left and right on smaller screens). There are lots of labeled tables, explanations of what they mean, and even several links to calculations via Wolfram|Alpha. All the math is being worked out by your browser as the program runs, so you may need to be patient with slower computers.

If you're still reading because you're unsure what Markov chains are, they're not that difficult a concept, as long as they're explained clearly. The rest of this post will deal with the basic concepts. Below is an excellent and clear (and short!) introduction to the concept.

What I realized is that I could represent the targeting of one planet by another as one state, and each of the possible outcomes as individual states. From this, I could build a transition probability matrix, as explained in the video and this visual explanation of Markov chains.

Now, the video discusses the idea of a starting probability vector as a starting point. In the Mutab/Neda/Sogal puzzle, however, we're really only interested in the long term probabilities themselves, the effects over the long term, and not so much a particular starting point, referred to as a stability distribution matrix.

As an example, imagine a 2-planet battle between Mutab (100% deadly) and Neda (80% deadly). If we list starting states from top to bottom (yes, I know this is opposite of how Markov chains are usually done) as, “Mutab fires against Neda”, “Mutab wins”, “Neda fires against Mutab”, and “Neda wins”, and label the resulting states the same way from left to right, then we can assign corresponding probabilities. The probability of going from “Mutab fires against Neda” to “Mutab fires against Neda” is 0, the probability of going from “Mutab fires against Neda” to “Mutab wins” is 1, and the probabilities of going from “Mutab fires against Neda” to “Neda fires against Mutab”, or “Neda wins” are both 0, so our first row would read (0 1 0 0). Continuing through all the probabilities between just Mutab and Neda, we get the following matrix:

Notice the 1s in the 2nd and 4th rows. Those are absorbing states. The 1 in the 2nd row basically says, the probability of going from “Mutab wins” to “Mutab wins” is 1 (100%). The 1 in the 4th row says that the probability of going from “Neda wins” to “Neda wins” is 1. They serve as an endpoint.

Where does this all wind up? Well, if we run these probabilities over 1,000 generations to get the long-term outlook (the stability distribution matrix mentioned earlier) by raising the above matrix to the 1,000th power, we get the following results:

Read with the original labels, this tells us that, over the long term, if Mutab is the first one to fire, then it's probability of survival is 1, and Neda's is 0. Conversely, if Neda is the first one to fire in that two-world battle scenario, then it's probability of survival is 80%, while Mutab's is only 20%. Yes, we figured that much out early on, but when it comes to tougher probabilities, such as the long-term probabilities between Neda and Sogal, this is a very helpful tool.

Once you've understood all that, you're ready to go through the step-by-step explanation I developed!


Grey Matters is Back!

Published on Tuesday, March 14, 2017 in , , ,

Mehran Moghtadaei's Pi Digit GraphicYes, I did take more than an extended break after my 10th blogiversary post, not posting at all in 2016, but with Pi Day coming around again, it seemed like a good time for a return! I probably won't have a regular posting schedule for sometime, as other commitments are keeping me busy, but I promise not to ignore this blog as I have been for about the past 1½ years.

While I've been thinking about returning on my own, one force that really pushed me over the edge to return to blogging is Brian Brushwood from Scam School. He recently used two of my submissions, and even encouraged people to go to Grey Matters!

The first of these two was posted back on January 18th. This was an update to Penney's Game, which was first taught on Scam School in their Sept. 15, 2010 episode (to which I also contributed!). Replacing cards with coins not might seem like such a big deal, it actually does have a significant effect. Coins can't run out of heads or tails, but cards can run out of reds and blacks. Watch the full episode and read more detail about the game here to understand it better.

Moving from cards and coins, we turn to dice. Here's an unusual dice scam from their March 1st episode. This one involves people picking how many dice of 5 they want, leaving you with at least 1 of them, and you're always able to predict the outcome. It seems like the odds are against you, but watch closely. At about the 3:30 mark, Brian asks the ladies how they think it's done. The theories included things such as particular numbers to pick, loaded dice, and changing the prediction based on previous evidence. The answer, as it so often is, is simple probability.

Even with all the troubles people have with most branches of math, probability is often the easiest to misunderstand and get wrong. As a result, many probability concept come across as counter-intuitive.

That's all for now. But I assure you, the time between this post and the next post will not be as long as the last post and this one.


Leapfrog Division IV

Published on Thursday, October 29, 2015 in , , ,

x divided by y fraction iconWhile I normally do my Leapfrog Division posts about a year apart, I though I'd wrap up this mental division series just 1 week after the previous entry.

In this post, you'll learn to mentally divide by numbers ending in 2!

STARTING POINTS: This is the most advanced technique of all of the Leapfrog Division posts, so you should be familiar with and practice the the previous techniques. Not only does this employ the basic ideas taught in the original Leapfrog Division post, but also the subtraction from 9 idea used in Leapfrog Division II, AND both the doubling and halfway-comparison concepts from Leapfrog Division III. If you comfortable with all of these concepts, then you're ready to move on to this version.

This version also introduces a new idea to the Leapfrog Division series: The stopping rule. In the previous versions, you could stop either when you realized the numbers were going to repeat, or when you didn't need any further precision. While the same is true here, in this version, you'll also need to stop when you get a quotient of 5, and a remainder of 0. You'll understand this better, including the exceptions, as you work your way through the technique.

THE TECHNIQUE: For our first example, we'll use 1732. As in the technique for dividing by numbers ending in 1, we will always start by reducing the numerator by 1, giving us 1632. Similar to the method for dividing by numbers ending in 8, we're also going to compare numbers to the half of the denominator. Anytime the numerator is greater than or equal to half of the original denominator, we'll reduce it by 1.

In the case of 32, half of that is 16, so we ask if the current numerator is greater than or equal to 16. In this example, it's currently 16 (exactly equal to half!), so we reduce by 1 more, giving us a division problem of 1522. As with all the Leapfrog Division techniques, we're now going to round the denominator to the nearest multiple of 10, and then divide it by 10. So, the problem becomes 153.

You shouldn't be surprised that we're going to divide this out using quotients and remainders. Starting with 152, we get:

  • 15 ÷ 3 = 5 (remainder 0)
Naturally, you write the quotient down right away, with a 0 and a decimal in front, as in 0.5. Ordinarily, the stopping rule might tell us to stop here. After all, we have a quotient of 5, and a remainder of 0. However, since 1732 (our original problem) isn't exactly 0.5, there's definitely more numbers to calculate, so we'll continue. We should still keep the stopping rule in mind for later, however.

From here, you're going to use the doubling idea as taught in Leapfrog Division III, in which you double numbers, but only keep the ones (units) digit. 5 doubles to 0, because 5 × 2 = 10, and we only keep the ones digit, which is 0. Next, as in Leapfrog Division II, you're going to subtract the quotient from 9. In this example, 9 - 0 = 9, so the new quotient is now 9. Leapfrogging the remainder, 0, to the front of the quotient, we know have 09, or simply 9.

Before dividing, we need to ask whether 9 is greater than or equal to 16. It isn't, so we don't decrease the number at this stage. After that question, only then do we do the division again:
  • 9 ÷ 3 = 3 (remainder 0)
We write the 3 down, giving us 0.53 so far. 3 doubled becomes 6, and 9 - 6 = 3. Leapfrogging the remainder of 0 in front, we have 03, or just 3. Is 3 greater than or equal to 16? No, so there's no decrease this time, either. The next division problem yields:
  • 3 ÷ 3 = 1 (remainder 0)
So far, our mental work has given us an answer of 0.531. Repeat once more. Double the 1 to get 2, subtract 9 - 2 to get 7, and put the remainder 0 in front of the 7, giving us a new divisor of 07. Is 7 greater than or equal to 16? No, so there's no decrease. Moving on to the next division:
  • 7 ÷ 3 = 2 (remainder 1)
Now we have 0.5312. 2 doubled becomes 4, and 9 - 4 = 5. Leapfrogging the 1 in front gives us 15. Is 15 greater than or equal to 16? No, so there's no decrease. Obviously, we can move on to the next division:
  • 15 ÷ 3 = 5 (remainder 0)
At this point, with 0.53125 as our current answer, you'll note we have a quotient of 5 and a remainder of 0. This means that the stopping rule kicks in. So, our final result is 0.53125, which is exactly what 1732 equals!

Now that you understand the steps, let's work out 1922 as a second example. We start by reducing 19 by 1, which is ALWAYS the first step, giving us 1822. Half of 22 is 11, and 18 is greater than 11, so we decrease it by 1 again, leaving us with 1722. Rounding the denominator down and dividing by 10, our starting problem should be 172. We start there, and work through the problem this way:
  • 17 ÷ 2 = 8 (remainder 1)
    (8 doubles to 6, 9-6=3, 1 makes it 13, which is MORE than 11, so 13 - 1 = 12.)
  • 12 ÷ 2 = 6 (remainder 0)
    (6 doubles to 2, 9-2=7, 0 makes it 07, which is less than 11.)
  • 7 ÷ 2 = 3 (remainder 1)
    (3 doubles to 6, 9-6=3, 1 makes it 13, which is MORE than 11, so 13 - 1 = 12.)
Since we're already back to dividing by 12, you can see that this is going to repeat. Writing down just the quotients, we get the correct answer of 1922 ≈ 0.863!

TIPS: Yes, this has more steps than any of the other approaches taught in the Leapfrog Division series, and it's not difficult to confuse the steps of the various versions. The solution, as always, is practice, practice, practice!

You may have noticed that I referred to this as the last post in the Leapfrog Division series. Why is that? Because using the 4 different techniques I've taught, you can actually handle dividing by most numbers with just a little adjustment. How do you handle numbers ending in...
So, every number except those ending in 5 or 0 are covered. That's good incentive to practice these techniques, as you can amaze many people with the ability to handle almost every division problem thrown at you. I hope you've found this series enjoyable and useful.


Leapfrog Division III

Published on Friday, October 23, 2015 in , , ,

x divided by y fraction iconIn 2013, I posted about Leapfrog Division, which was A.C. Aitken's approach for mental division by numbers ending in 9. In 2014, I built on this method with Leapfrog Division II, an approach for mentally dividing by numbers ending in 1.

It's 2015, so it's time for another update to the Leapfrog Division technique. This time, you'll learn the method for mental division by numbers ending in 8!

STARTING POINTS: You'll want to be very familiar with the process of dividing numbers by 9, as taught back in the Leapfrog Division post. There are a few extra steps in this version, as compared to the original version, so being well versed in the original is imperative. You may also find it helpful to have practiced the technique for dividing by numbers ending in 1, as taught in Leapfrog Division II, but that's not as essential to this approach.

When teaching this technique, I'm going to be referring to doubling a given number, but they're doubled in a special way. As used in this technique, you double the number, but only keep the ones (units) digit. Ordinarily, you would double 5 to get 10, but here you only need to remember the 0. In a similar manner, 6 doubled will give you 2 (12, with the tens digit dropped), 7 doubled will give you 4, 8 doubled will give you 6, 9 doubled will give you 8, and 0 doubled will give you 0.

THE TECHNIQUE: As our very first working example, we'll work out the decimal equivalent of 1318. Just as before, you're going to start by rounding up the denominator (the bottom number) to the nearest multiple of 10, and then drop the 0. In our example, that means that our fraction gets changed to 1320, and dropping the 0 from the denominator changes this to 132.

We're going to ask a question here which will be asked over and over again, and this question will help give us the correct total. Is our current numerator greater than or equal to half of the original (before rounding) denominator? If so, we MUST add 1 to it. For example, half of our original example denominator, 18, comes to 9. So, we're going to be asking at the start, and several points afterward, whether our current numerator is equal to or greater than 9. To start, we realize that 13 is equal to or greater than 9, so we add 1, giving us 142 as our actual first problem to solve.

We're going to work this out in a similar manner as before, solving this division problem with a quotient and a remainder. As you go, you're going to write down quotients as you go, and keep remainders in your head. Our first division yields:

  • 14 ÷ 2 = 7 (remainder 0)
At this point, you can write down 7 as the first number after the decimal point, and begin developing and solving the next problem.

How do we take the next step? First, the quotient (the 7 in our example answer above) must be doubled. Don't forget that we drop the tens digit when doubling! So, we double 7 to get 14, and drop the tens digit, leaving us with 4. The remainder (0, in the problem above) then “leapfrogs” to the front of the 4, giving us 04 as our new numerator (which is just equal to 4, of course).

We ask ourselves one more time, is our current numerator (4) greater than or equal to 9? In this case, 4 isn't greater than 9, so we don't add 1. After that, we divide by 2 again to get:
  • 4 ÷ 2 = 2 (remainder 0)
So, we can write down 2 as the next digit in the decimal answer, and move on to the next digit.

2 (the quotient) gets doubled again, to make 4, and the remainder of 0 leapfrogs in front to give us 04, or 4, once again. Is this new 4 greater than or equal to 9? No, so we leave it alone. Dividing by 2 one more time yields:
  • 4 ÷ 2 = 2 (remainder 0)
You write down the quotient 2 again. At this point, you can probably already see that this is going to repeat endlessly. If you check against a calculator, you find that 1318 is indeed 0.722..., with the 2 repeating endlessly.

Just to help lock in the technique, let's try and work out the decimal equivalent of 928. We have to remember to keep asking ourselves about half of the original denominator, which is 14 this time. Is 9 equal to or greater than 14? No, so we won't add 1 at this point. The denominator gets rounded up to 30, and we drop the 0 to leave us with a starting calculation of 93:
  • 9 ÷ 3 = 3 (remainder 0)
    (3 doubles to 6, 0 in front makes 06, which is less than 14.)
  • 6 ÷ 3 = 2 (remainder 0)
    (2 doubles to 4, 0 in front makes 04, which is less than 14.)
  • 4 ÷ 3 = 1 (remainder 1)
    (1 doubles to 2, 1 in front makes 12, which is less than 14.)
  • 12 ÷ 3 = 4 (remainder 0)
    (4 doubles to 8, 0 in front makes 08, which is less than 14.)
  • 8 ÷ 3 = 2 (remainder 2)
    (2 doubles to 4, 2 in front makes 24, which is MORE than 14, so 24 + 1 = 25.)
  • 25 ÷ 3 = 8 (remainder 1)
    (8 doubles to 6, 1 in front makes 16, which is MORE than 14, so 16 + 1 = 17.)
  • 17 ÷ 3 = 5 (remainder 2)
    (5 doubles to 0, 2 in front makes 20, which is MORE than 14, so 20 + 1 = 21.)
  • 21 ÷ 3 = 7 (remainder 0)
    (7 doubles to 4, 0 in front makes 04, which is less than 14.)
  • 4 ÷ 3 = 1 (remainder 1)
    (1 doubles to 2, 1 in front makes 12, which is less than 14.)
Double checking with our calculator once again, we find that 928 is equal to 0.32142857..., with the 142857 repeating. Actually, if you know the 142857 pattern from knowing your 7ths, and you realize that 28 is a multiple of 7, you should realize that you'll eventually run into the 142857 pattern from there.

TIPS: As always, the biggest tip is practice, practice, practice! Once you can divide by numbers ending in 8, you should also realize that you can divide by numbers ending in 4. If you want to divide by a number ending in 4, just double both numbers in the problem. If you need to work out 1724, for example, just double both numbers, resulting in 3448, and work the problem out from there, as described in the technique section. As a matter of fact, you'll get a great deal of practice if you work out 3448 on your own, right now.


Simple math? Not so simple

Published on Sunday, May 10, 2015 in , ,

mattbuck's Bayes' Theorem neon sign photoJust over a month ago, TheWeek.com posted an article titled The simple math problem that blows apart the NSA's surveillance justifications. It concerned the probability of detecting terrorists, when you have a near-perfect terrorist-detecting machine.

It turns out that the simple math isn't so simple.

Let's start with the question itself:

Suppose one out of every million people is a terrorist (if anything, an overestimate), and you've got a machine that can determine whether someone is a terrorist with 99.9 percent accuracy. You've used the machine on your buddy Jeff Smith, and it gives a positive result. What are the odds Jeff is a terrorist?
A better way to state the question is, “Given that the machine has identified Jeff as a terrorist, what is the probability Jeff is actually a terrorist?” Questions like this are known as conditional probabilities, and it turns out that Bayes' Theorem helps answer questions like this very effectively. If you're not already familiar with Bayes' theorem, read that post and watch the videos to better understand it before proceeding.

Unfortunately, the linked article above doesn't employ such computations, so we have to go about it ourselves. Let's assume the 99.9% (0.999) accuracy of the machine applies to detecting not only terrorists, but to identifying innocent people, as well. In turn, that means that the machine has a 0.1% (0.001) chance of identifying an innocent person as a terrorist, or identifying a terrorist as an innocent person. So, we have four different probabilities:

Chance that an actual innocent is identified as a terrorist: 0.001 (False +)
Chance that an actual innocent is NOT identified as a terrorist: 0.999 (True -)
Chance that an actual terrorist is identified as a terrorist: 0.999 (True +)
Chance that an actual terrorist is NOT identified as a terrorist: 0.001 (False -)

Let's put these numbers in the following table:

  Is a terrorist Is innocent
Identified as terrorist 0.999 (True +) 0.001 (False +)
Identified as innocent 0.001 (False -) 0.999 (True -)

Now that we've got the probabilities in order, let's see what happens when 1 terrorist and 999,999 innocent people are thrown into the mix. We'll multiply both entries in the “Is a terrorist” column by 1, to represent the 1 terrorist, and both entries in the “Is innocent” column by 999,999, to represent the 999,999 innocent people:

  Is a terrorist Is innocent
Identified as terrorist 0.999 (1 × 0.999) 999.999 (999,999 × 0.001)
Identified as innocent 0.001 (1 × 0.001) 998,999.001 (999,999 × 0.999)

We can double-check that the table has been correctly constructed, because all the numbers add up to 1 million. This covers all the data, so now we're ready to tackle the original question.

Remember that the question itself is “Given that the machine has identified Jeff as a terrorist, what is the probability Jeff is actually a terrorist?” In other words, we aren't concerned with the possibility of being identified as an innocent, as identification as a terrorist is already a given. All we have to do here is trim the “Identified as innocent” row out of the table completely:

  Is a terrorist Is innocent
Identified as terrorist 0.999 999.999

At this point, don't forget the basic probability formula: Probability = (targeted outcome) ÷ (total possibilities). What are the total possibilities here? 0.999 + 999.999 = 1000.998. What is the targeted outcome? It's that Jeff is a terrorist, which is 0.999. So, the probability is 0.999 ÷ 1000.998 ≈ 0.000998, or about a 0.0998% chance.

In more practical terms, once the 99.9% accurate machine has identified Jeff has a terrorist, there's still only a 1 in 1,002 chance that he's actually a terrorist! Granted, this isn't radically different from the 1 in 1,000 chance posted in the original article. However, in math, the path you take is just as important as the results.