Will Lil and Bill meet at the malt shop? This comes from page 38 of Digital Dice: Computational Solutions to Practical Probability Problems, by Paul J. Nahin. Check it out at amazon to get more puzzles like it.
Lil and Bill agree to meet at the malt shop sometime between 3:30 and 4:00 pm later in the afternoon. They're pretty casual about the details, because each knows that the other, while he or she will show up during that half hour, is as likely to do so at any time during that half hour as at any other time. If Lil arrives first, she'll wait 5 minutes for Bill, and then leave if he hasn't appeared by then. If Bill arrives first, however, he'll wait seven minutes for Lil before leaving if she hasn't appeared by then. Neither will wait past 4:00. what's the probability that Bill and Lil meet? What's the probability of their meeting if Bill reduces his wait to time to match Lil's (Both times are 5 minutes)? And if both times are 7 minutes?
“Aristotle maintained that women have fewer teeth than men; although he was twice married, it never occurred to him to verify this statement by examining his wives' mouths.” - Bertrand Russell on Aristotle's Mistake
Monday, October 13, 2014
Friday, October 10, 2014
Answer to Monday.
import randomSo here it, a python answer to Mondays problem. So far so good, aimed fro three posts this week, got three posts up this week. It's really the answer in the book, converted to a python answer. Have a good weekend, and stay safe.
M = 24
totalCorrect = 0
for k in range(1, 100000):
correct = 0
term = random.randrange(1, M)
for j in range(1, M):
if term = j:
correct += 1
totalCorrect = totalCorrect + correct
print(totalCorrect/1000000)
Thursday, October 9, 2014
Lottery probablity, part 1
Once, a few years ago, a real honest-to-god doctor diagnosed me with ADHD, with less "hyper active" and more "focus" problems. I can focus too much on a task, which means other tasks and things get ignored. Isn't that cool? Anyways, I spent the morning working on a single task in coding. One task. After a while, it's not "working" on the problem. Just "deliberately breaking the code in as many ways as possible, then googling the error." It's done, and it's quite around here, so on to today's topic. The lottery.
About a month ago when I started reading the book "The Drunkards Walk: How Randomness Rules Our Lives" someone decided to tell me how they used math to almost win the lottery. His story was:
I think I'll break this post up into 2 posts, because of the aforementioned ADHD. There's a lot of ground to cover, and my mind goes weird when I focus on math and programming too much.
First things first, the parameters of the problem. According to the website for the powerball, the ticket costs two dollars, and the player picks 6 numbers. 5 numbers are 1 thru 65, and the 6th number is 1 thru 35. Then there are various combos that win money, but no one cares. They want the secret to the jackpot. Also, as I sit here staring at the rules, missed 3 numbers is not impressive at all, since that's about 50%. I wonder what he was playing?
In probability, there is independent events and dependent events. Independent events are events that don't depend on each other. Yup. Tradition states that the example used here is dice. Dice are independent, if a die is rolled, then it's reset before it's rolled again. If a die is rolled 6 times, then each time the probability doesn't depend on the previous roll. Contrast that with cards, where if a card is pulled from a deck of 52, the chance of predicting the card drawn is 1 in 52. On the second draw, it's 1 in 51. That's a dependent event. Independent is much easier to calculate. The chance of rolling a 5 is 1 in 6. To figure out the chance of rolling a 5 twice, multiply the probability. 1/6 * 1/6 is 1/36. 3 times in a row, 1/(63) or 1/216. Simple. This would only really apply to the lottery if they drew the number out of the bin, made a note of it, then put it back into the bin. It would make the calculation easy: 1/(655) for the top line, and 1/35 for the powerball, and you know what? No one talks about that possibility. I'm going to leave that alone for now, and come back in an edit, or tack it on a later post once it gets worked out.
A dependent event is more in line with cards and this powerball thing. Pick the number 4 10 18 32 12. The chance of a 4 on the first draw is 1 in 65. No matter the outcome of the first draw, the chance of a 10 on the second is 1 in 64. The 12 on the 5 draw is 1 in 60. This can be attack the same way as before with conditional probability. The idea that IF a four is pick on the first draw, then we move onto the next one. The calculation becomes 1/65 * 1/64 * 1/63 * 1/62 * 1/61 * 1/35. That gives us the probability.
About a month ago when I started reading the book "The Drunkards Walk: How Randomness Rules Our Lives" someone decided to tell me how they used math to almost win the lottery. His story was:
I studied the winning numbers for the previous 6 months, made note of which number came up in which spot, then used those numbers as my guesses. I missed three numbers.I can't do the story justice, sadly. The story didn't sit right with me, but at the time I only managed a half- assed "But the numbers should be random." Really, when it comes to random numbers in the lottery, if it is a truly random system, then with a large enough data set the probabilities start showing themselves. So, I put the question in my pocket, and decided that it would make for a semi-decent blog post for this month.
I think I'll break this post up into 2 posts, because of the aforementioned ADHD. There's a lot of ground to cover, and my mind goes weird when I focus on math and programming too much.
First things first, the parameters of the problem. According to the website for the powerball, the ticket costs two dollars, and the player picks 6 numbers. 5 numbers are 1 thru 65, and the 6th number is 1 thru 35. Then there are various combos that win money, but no one cares. They want the secret to the jackpot. Also, as I sit here staring at the rules, missed 3 numbers is not impressive at all, since that's about 50%. I wonder what he was playing?
In probability, there is independent events and dependent events. Independent events are events that don't depend on each other. Yup. Tradition states that the example used here is dice. Dice are independent, if a die is rolled, then it's reset before it's rolled again. If a die is rolled 6 times, then each time the probability doesn't depend on the previous roll. Contrast that with cards, where if a card is pulled from a deck of 52, the chance of predicting the card drawn is 1 in 52. On the second draw, it's 1 in 51. That's a dependent event. Independent is much easier to calculate. The chance of rolling a 5 is 1 in 6. To figure out the chance of rolling a 5 twice, multiply the probability. 1/6 * 1/6 is 1/36. 3 times in a row, 1/(63) or 1/216. Simple. This would only really apply to the lottery if they drew the number out of the bin, made a note of it, then put it back into the bin. It would make the calculation easy: 1/(655) for the top line, and 1/35 for the powerball, and you know what? No one talks about that possibility. I'm going to leave that alone for now, and come back in an edit, or tack it on a later post once it gets worked out.
A dependent event is more in line with cards and this powerball thing. Pick the number 4 10 18 32 12. The chance of a 4 on the first draw is 1 in 65. No matter the outcome of the first draw, the chance of a 10 on the second is 1 in 64. The 12 on the 5 draw is 1 in 60. This can be attack the same way as before with conditional probability. The idea that IF a four is pick on the first draw, then we move onto the next one. The calculation becomes 1/65 * 1/64 * 1/63 * 1/62 * 1/61 * 1/35. That gives us the probability.
Tuesday, October 7, 2014
Random NUmbers and intro to Stats
Thing about taking so much time off from something voluntary, it's really tough to get back in the right rhythm. It's hard to come back to a normal job, but one where I set the time to post, well that's just a new challenge.
Here is how it's going to be this month: Monday (or today, whatever) I'll post a puzzle I have from a book on Monte Carlo problems. A Monte Carlo method (or simulation, or experiment) is a "broad class of computational algorithms that rely on repeated random sampling to obtain numerical results; typically one runs simulations many times over in order to obtain the distribution of an unknown probabilistic entity."[1] This early in the morning I'm having trouble with definitions, but it's steps that a computer (or person, really) takes with random numbers in order to solve problems with random numbers. They are fairly easy to build. There are articles on how to run them in Excel or any similar spreadsheet program. Like I said, if you have the right random number generator, like a standard die or maybe some multi-sided dice, a person could do the simulation with paper and pencil. It just might be tedious.
Okay, so here is the problem, taken from the book "Digital Dice: Computational Solutions to Practical Probability Problems". I left my copy. . . somewhere. . . so this is the easy intro problem:
Here is how it's going to be this month: Monday (or today, whatever) I'll post a puzzle I have from a book on Monte Carlo problems. A Monte Carlo method (or simulation, or experiment) is a "broad class of computational algorithms that rely on repeated random sampling to obtain numerical results; typically one runs simulations many times over in order to obtain the distribution of an unknown probabilistic entity."[1] This early in the morning I'm having trouble with definitions, but it's steps that a computer (or person, really) takes with random numbers in order to solve problems with random numbers. They are fairly easy to build. There are articles on how to run them in Excel or any similar spreadsheet program. Like I said, if you have the right random number generator, like a standard die or maybe some multi-sided dice, a person could do the simulation with paper and pencil. It just might be tedious.
Okay, so here is the problem, taken from the book "Digital Dice: Computational Solutions to Practical Probability Problems". I left my copy. . . somewhere. . . so this is the easy intro problem:
- A clueless student faced a pop quiz: a list of 24 presidents of the 19th century and another list of their terms in office, but scrambled. The object was to match the president with the term. He had to guess every time. On average, how many did he guess correctly?
- Imagine this scenario occurs 1000 times. On average, how many matches (of the 24 possible) would a student guess correctly?
Wednesday, October 1, 2014
IWSG for the month of October
I've been really quiet for the last few weeks. No family crises, no health problem, I was a little busy with my job, but the real reason I haven't been blogging is good, old fashioned humiliation. Yes, something real to talk about on this month's IWSG! Which, by the way, is brought to by Alex J. Cavanaugh. Click the picture if you want to sign up.
I tried an experiment here. Experiments are good, they keep things fresh. What I wanted to do was use the month build up as way to further explore the subject that my math group talks about on the fourth Saturday of every month. I figured three days a week was good, I could fill in the other two days with stuff about learning programing, and the weekend would be dedicated to writing about whatever. That was really ambitious apparently.
urWhat I did right was figure out my topics in advanced. What I did wrong was not do any sort of outline as well. Life is busy, it turns out, no matter who you are. Without the proper prep everything just falls apart and it gets stressful. Having dealt with failures before, I knew at a certain point that I could drop the whole thing entirely and do other things. Page views is not worth my sanity, and I could try again in a month.
Here I am the next month to try again. Still doing three days a week with this thing, but the other 4 days will just be me talking about whatever. No attempt at anything really ambitious. That's not true. This will still tie into the math group on the fourth Saturday, and I'm working to tie this into a Nerd Nite talk I'm giving on November 5. Again, I've got an outline of my month planned, hopefully it's lose enough but strong enough I get stuff done. If I can stick to my plan of three days a week, 3 months from now I can work on making it more ambitious.
Ok, now I'm ready to kick ass.
I tried an experiment here. Experiments are good, they keep things fresh. What I wanted to do was use the month build up as way to further explore the subject that my math group talks about on the fourth Saturday of every month. I figured three days a week was good, I could fill in the other two days with stuff about learning programing, and the weekend would be dedicated to writing about whatever. That was really ambitious apparently.
urWhat I did right was figure out my topics in advanced. What I did wrong was not do any sort of outline as well. Life is busy, it turns out, no matter who you are. Without the proper prep everything just falls apart and it gets stressful. Having dealt with failures before, I knew at a certain point that I could drop the whole thing entirely and do other things. Page views is not worth my sanity, and I could try again in a month.
Here I am the next month to try again. Still doing three days a week with this thing, but the other 4 days will just be me talking about whatever. No attempt at anything really ambitious. That's not true. This will still tie into the math group on the fourth Saturday, and I'm working to tie this into a Nerd Nite talk I'm giving on November 5. Again, I've got an outline of my month planned, hopefully it's lose enough but strong enough I get stuff done. If I can stick to my plan of three days a week, 3 months from now I can work on making it more ambitious.
Ok, now I'm ready to kick ass.
Subscribe to:
Posts (Atom)