Link to a post about the shared birthday problem.
Link to a post about the Game Show problem, a.k.a. the Monty Hall problem. (many topics discussed, this topic at the bottom of the post.)
Probability of r successes in n dependent trials using sampling without replacement, which is like drawing cards from a deck.
A new use for independent probability: Missing a rare side effect. Let us consider a drug company running tests on a new drug. The tests are designed to check the drug's effectiveness in comparison to other drugs on the market, but they are also designed to see if the subjects experience side effects. If you've ever listened to a drug commerical on TV, you know that some side effects can be quite dangerous. If the probability of a side effect is p and the size of the sample is n, the expected value for the frequency is np.
Example: Let's say the drug company is testing a new drug on 500 subjects. Let's also stipulate there is a fairly rare side effect that we should see in 1% of the population, so p = .01. 500 * .01 = 5, so the expected value of people with the side effect in the sample is 5. Since the expected value is a whole number, this means the most likely number people with the side effect is 5. Let's do the binomial distribution for 4, 5 and 6, rounding to four places after the decimal.
Probability of exactly 4 people out of 500 having the side effect:
500 nCr 4 * .01 ^ 4 * .99 * 496 = .1760 or 17.6%
Probability of exactly 5 people out of 500 having the side effect:
500 nCr 5 * .01 ^ 5 * .99 * 495 = .1764 or 17.64%
Probability of exactly 6 people out of 500 having the side effect:
500 nCr 6 * .01 ^6 * .99 * 494 = .1470 or 14.70%
As we can see, the odds of 5 out of 500 are slightly greater than 4 out of 500, and about 3% more than 6 out of 500. No other outcome is more likely than 5 out of 500.
Here's a different question: what are the chances of 0 out of 500? The reason to ask this is if the trial misses the side effect completely and drug goes to market, the company could face a lot of lawsuits they didn't expect when the side effect starts showing up in the much larger sample of patients taking the drug.
Probability of 0 people out of 500 having the side effect:
500 nCr 0 * .01 ^0 * .99 * 500 = .0066 or 00.66%
(Note: when we have "n choose 0" the answer is always 1, and likewise any non zero number raised to the power of 0 is one. For this problem only, we can just type in the last term (1 - p)^n
Because the sample was large enough and the side effect was not all that rare, the odds of a sample missing this side effect are relatively low. But what if the side effect were rarer, say 1 in 400, which is the decimal .0025. This changes the numbers, of course. The expected value is now 500 * .025 = 1.25, which means the most likely event should be either 1 person or maybe 2 people showing the side effect. Let's look at 0, 1 and 2 people having the side effect.
Probability of exactly 0 people out of 500 having the side effect:
500 nCr 0 * .0025 ^ 0 * .9975 * 500 = .2861 or 28.61%
Probability of exactly 1 person out of 500 having the side effect:
500 nCr 1 * .0025 ^ 1 * .9975 * 499 = .3585 or 35.85%
Probability of exactly 2 people out of 500 having the side effect:
500 nCr 2 * .0025 ^ 2 * .9975 * 498 = .2242 or 22.42%
So the most likely event is to have one person showing the side effect, which will happen about 36% of the time. But the next most likely event is not 2 out of 500 but 0 out of 500, which happens over 28% of the time. 1 in 400 people showing a side effect might not seem that high, but a successful drug can be given to hundreds of thousands of patients, possibly more, and having 1 in every 400 showing a very bad side effect could get very expensive for the company.
Here are some practice problems. Assume the sample size is n = 1000 and we are interested in 0 people showing the side effect. Round the answers to the nearest tenth of a percent.
a) the side effect shows up in 1 in 500 patients
b) the side effect shows up in 1 in 1,000 patients
c) the side effect shows up in 1 in 1,500 patients
Answers in the comments.
Showing posts with label probability. Show all posts
Showing posts with label probability. Show all posts
Tuesday, September 15, 2015
Monday, March 17, 2014
Notes for March 13
Besides review the new topic, for today was another problem in probability. If we have a group of n people and none of them were born on Leap Day (February 29, very rare), what is the probability that at least two people have the same birthday?
Trying to do this problem directly is very difficult, so instead we try to figure out the probability of the opposite problem.
If we have n people and none of them are born on February 29, what is the probability of at least two people sharing a birthday? (Note: we are not asking for the same year, just the same day.)
Figuring out this probability directly is very difficult, but figuring out the opposite probability can be done using methods we already know.
The opposite statement: If we have n people and none of them are born on February 29, what is the probability of none of them sharing a birthday?
Let's look at the problem step by step.
Only one person
Clearly, with just one person, we can't have two people sharing a birthday. Any of the 365 days this person is born on will mean he doesn't have a match, because there is no one to match with.
p(not sharing) = 365/365 = 1
p(at least two share) = 1 - 1 = 0
Two people
With two people, it possible but very unlikely for them to share. If we want to know about not sharing, the first person has 365 days that are acceptable but the second person has only 364.
numerator: 365 × 364
denominator: 365 × 365
Rounding to four places after the decimal
p(not sharing) = .9973
p(at least two share) = 1 - .9973 = .0027
Three people
With three people, it possible but very unlikely for them to share. If we want to know about not sharing, the first person has 365 days that are acceptable but the second person has only 364, but the third person has 363 days on which he or she could be born.
numerator: 365 × 364 × 363
denominator: 365 × 365 × 365
Rounding to four places after the decimal
p(not sharing) = .9918
p(at least two share) = 1 - .9918 = .0082
The probability of sharing is still small, but it's growing faster than you might expect. The formula for no shares among n people is the fraction
365 nPr n
365 ^ n
Many people are surprised how low n is when this fraction is less than 50%. If there are 23 people in a room - none of them with a Leap Day birthday - the probability that all of them have a unique birthday in the group is
365 nPr 23
365 ^ 23
which is .4927, rounded to four places. The odds of sharing has risen to .5073, or slightly over 50%
Thursday, February 20, 2014
Notes for February 18 and 20
A probability is a number between 0 and 1, inclusive, and is represent by p(event) if part of a sample or p-hat(event) if part of a population.
A probability space or event space is a list of what we call the simple events. The list follows two rules.
1. Every simple event is mutually exclusive from every other simple event, which means the cannot both happen simultaneously. For example, if I flip one coin, it cannot land "heads" and "tails" simultaneously.
2. When we add up the probabilities of all the simple events, the sum is 1. What this means is the simple events (sometimes called simple outcomes).
There are ways to create new probabilities from a set of simple events. The first methods we will discuss are AND, OR and NOT. Let's start with the most basic, NOT.
p(NOT x) is the probability that the event x will not happen. It is sometimes written as q(x) instead. It is always true that
p(x) + p(NOT x) = p(x) + q(x) = 1
Example #1: If we flip a coin, we have two possibilities, heads and tails. We usually assume that p(heads) = .5 and p(tails) = .5, but that doesn't have to be true. What is true in this cases with a categorical variable that has only two legitimate values is that p(NOT heads) = q(heads) = p(tails), and the sum is 1. This means if p(heads) = .51, then q(heads) = 1 - .51 = .49.
If we roll a six-sided die, we have six possible outcomes, a 1, a 2, a 3, a 4, a 5 or a 6. The probability for not rolling a 1 is
p(NOT 1) = p(2) + p(3) + p(4) + p(5) + p(6)
Because these are simple events, we don't have to worry about overlap. And again, instead of calling it p(NOT 1), we can call it q(1).
If two events A and B are mutually exclusive, then
p(A OR B) = p(A) + p(B)
If they are not mutually exclusive, that means p(A AND B) does not equal zero, and the rule for finding OR changes to
p(A OR B) = p(A) + p(B) - p(A AND B)
This is most easily explained with a contingency table. Let's say we have two variables for a game, one called Result (which is either a win or a loss) and Setting (which is either home or away). The easiest way to represent this situation is a contingency table, like the one below listing wins and losses for the Warriors so far this season, broken into home record and away record.
___H || A|| Total
W |16||15|| 31
L |10||12|| 22
|26||27|| 53 = grand total
p(Home) = 26/53, which rounded to the nearest thousandth is .491
p(Away) = 27/53, which rounded to the nearest thousandth is .509. Notice that p(Home) = q(Away) and vice versa.
p(Wins) = 31/53, which rounded to the nearest thousandth is .585
p(Losses) = 22/53, which rounded to the nearest thousandth is .415. Notice that p(Wins) = q(Losses) and vice versa.
p(Wins AND Home) = 16/53, which rounded to the nearest thousandth is .302. What this represents is the number of home wins divided by the total number of games.
p(Wins OR Home) is the probability that a game picked at random is either a home game or a win. We will get this by adding all the wins to all the home games, but we have to subtract the home wins, because they were counted twice.
p(Wins OR Home) = 31/53 + 26/53 - 16/53 = 41/53 or .774 rounded to the nearest thousandth.
Besides AND, OR and NOT, we have the qualifier GIVEN. In a contingency table, this means we only look at the number is a single row or column.
p(Wins GIVEN Home) = 16/26 or .615 rounded to the nearest thousandth.
p(Home GIVEN Wins) = 16/31 or .516 rounded to the nearest thousandth.
Notice that p(Wins) = .585 but p(Wins GIVEN Home) = .615. When these numbers are different, we say that the two categories Wins and Home are dependent. If they were the same, we would say the categories are independent. A contingency table that was independent might look like this
___H || A|| Total
W |16|| 8|| 24
L |10|| 5|| 15
|26||13|| 39 = grand total
Now, p(Wins) = p(Wins GIVEN Home) = p(Wins GIVEN Away). This hypothetical win-loss record is at the same proportion whether on the road or at home.
Binomial distribution of an independent variable
If I say someone is a 70% free throw shooter, is every free throw attempt independent of what happened before? Often, we set up such an experiment assuming independence just to make our work simpler, but the human factor is involved, so in reality it's very likely to be dependent. Some people get frustrated after a few misses and will do worse. Others will learn from the mistakes of a few misses and figure out what they are doing wrong and make improvements. A player might be having a bad day for some reason, or might instead have excellent concentration or just really good luck that day. But again, these kinds of experiments are often set up as though each free throw trial is independent of what came before.
Let's look at flipping coins. A list of all possible events is called the event space. Here are some examples of event spaces.
Event space for flipping one coin
Heads (H)
Tails (T)
ways to get one head = 1
ways to get no heads = 1
Event space for flipping two coins
HH
HT
TH
TT
ways to get two heads = 1
ways to get one head = 2
ways to get no heads = 1
Event space for flipping three coins
HHH
HHT
HTH
HTT
THH
THT
TTH
TTT
ways to get three heads = 1
ways to get two heads = 3
ways to get one head = 3
ways to get no heads = 1

The list of numbers of ways to get r successes in n trials is often written in the pattern of the picture shown here, and this pattern is called Pascal's Triangle, at least in most of the world. The Italians call it Tartaglia's Triangle and the Chinese call it Yanghui's Triangle. None of these people actually invented it or claimed to have invented it. It's been around since before the time of Christ, and it has been studied all around the world.
While it is very common to see it presented in the form here as an equilateral triangle, it can also be presented where the first numbers in each row are lined up straight as follows
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
... etc.
It is standard to start counting the top row as row 0, and the left most column as column 0. For example, the 6 we see in the middle of the last row I typed in is row 4, column 2. Instead of having a copy of Pascal's Triangle around, our calculators have these numbers available. On Texas Instruments calculators, the function is under the probability menu. On the TI-30XIIs, the way to get that 6 is to type
4 [prb][right arrow]2[enter]
The calculator will read
4 nCr 2
6
All scientific calculators should have this function available, but all of them are slightly different. The TI-89 writes it as nCr(4,2) and Casio calculators write it as 4 C 2. I will pronounce it "4 choose 2", and when I type on the blog, I will type C(4,2). When I write it on the board or on tests, I will put a 4 on top of a 2 and surround both numbers with a large parentheses. These numbers are called the binomial coefficients.
The formula for finding the probability for exactly r successes in n independent trials where the probability of success on any single trial is p is shown here. In some books, they don't use the letter q, instead replacing it with (1-p). Likewise, sometimes w is replaced with (n-r). I use the extra letters and include the relationships between them. The letters r and w stand for right and wrong. The letter p and q are standard in probability texts for the probability of a success or a failure.Let's do an example. You are given a four question multiple choice test, each question having five possible answers. The test is given in a language you do not read, so all you can do is guess. Each question is independent from the others, meaning that if C is the right answer to the first question, it's also possibly the answer to the second. The probability p of a correct guess is 1 chance in 5, or .2, The probability of failure q is 1-.2 = .8, and of course p + q = 1.
Probability of no correct answers = C(4,0)*.2^0*.8^4 = .4096
Probability of exactly one correct answer = C(4,1)*.2^1*.8^3 = .4096
Probability of exactly two correct answers = C(4,2)*.2^2*.8^2 = .1536
Probability of exactly three correct answers = C(4,3)*.2^3*.8^1 = .0256
Probability of four correct answers = C(4,4)*.2^4*.8^0 = .0016
The expected value of correct answers is n*p, so in this case it's 4*.2 = .8, which isn't possible. You can't get a fraction of correct answers on a multiple choice test. The expected value in this case says that over the long run, a test like this should average .8 right answers out of four. As we can see, the most likely thing to happen is actually a tie for first, where getting either no answers right or one answer right both have a probability of about 41%. If you need to get three answers right to pass the test, the odds are less than 3% to get either three or four right, and the odds of getting everything right by chance is a very slim 16 chances in 10,000.
If you have a TI-83 or TI-84, there is a function under the distribution menu called binompdf(n,p,r). All you have to is enter the function, then the three values in the order given, separated by commas.
The function for three right in four trials with probability .2 at each trial is binompdf(4, .2, 3), which as we see above is .0256.
Practice problem.
The test is changed. There are now five multiple choice questions and four choices for each, but it is still given in a language you do not read.
Round the probabilities to four places after the decimal.
1. What is the expected value?
2. What is the probability of no correct answers?
3. What is the probability of exactly one correct answer?
4. What is the probability of exactly two correct answers?
5. What is the probability of exactly three correct answers?
6. What is the probability of exactly four correct answers?
7. What is the probability of five correct answers?
Answers in the comments.
Monday, June 29, 2009
Preview of class for 6/29
Today, we will be discussing distributions of numerical variables. Some variables are evenly distributed through all the values, other skew to have more high values than low, some are the other way around with more low than high.

A lot of data sets have what is called normal distribution, where the most common values are the ones closest to the average, with values much higher or much lower than average being much rarer, and the farther from average those values are, the rarer they become. This curve, known as the bell-shaped curve or the normal curve or the Gaussian curve represents the normal distribution, where the high point shows the density of the values that are near average, and the lower levels at both ends represent the scarcity of values farther away from average.

One of the reasons to find the standard deviation of a set of numbers is to calculate the z-score of a raw value x. This tells us how many standard deviations a value is away from the average. Negative z-scores are for numbers below average and positive z-scores are for values above average. z(x) = 0 only when x = x-bar, the value is exactly at average. The first four pages in the class notes let us change z-scores into proportions, and using these numbers we can talk about the probability of finding values greater than some value x, or the probability of finding values between two values, call them x1 and x2

A lot of data sets have what is called normal distribution, where the most common values are the ones closest to the average, with values much higher or much lower than average being much rarer, and the farther from average those values are, the rarer they become. This curve, known as the bell-shaped curve or the normal curve or the Gaussian curve represents the normal distribution, where the high point shows the density of the values that are near average, and the lower levels at both ends represent the scarcity of values farther away from average.

One of the reasons to find the standard deviation of a set of numbers is to calculate the z-score of a raw value x. This tells us how many standard deviations a value is away from the average. Negative z-scores are for numbers below average and positive z-scores are for values above average. z(x) = 0 only when x = x-bar, the value is exactly at average. The first four pages in the class notes let us change z-scores into proportions, and using these numbers we can talk about the probability of finding values greater than some value x, or the probability of finding values between two values, call them x1 and x2
Thursday, April 23, 2009
Class notes for 4/22
Random and deterministic
It's common for people to use the word random in a casual manner, but in the field of the philosophy of science, discussion of whether something can be considered random or not is a subject of intense debate. The opposite of random is deterministic, which is to say that when we perform a task, we understand the possible outcomes thoroughly. For example, putting a key in a lock is a deterministic act. Will the door open? Not necessarily. It might be the wrong key. The key might be correct, but it might have worn out over time. A brand new key in a lock that has been used might have edges that are too sharp. The lock could malfunction. Maybe the person didn't turn the key in the right direction. So deterministic does not mean, "If you do a, then b will also happen." It can be more complicated than that. But in a completely deterministic act, we have an expected outcome, and even when it fails, we have explanations of why it fails.
The problem of determinism versus randomness is not a yes/no situation. We have some acts we consider random, like flipping a coin or rolling a die or choosing a card from a deck. If done under certain circumstances, even these can be deterministic. If the deck is removed from the pack and unshuffled, the top card will be the way the cards were sorted at the factory, and so it is completely deterministic. Some card tricks are done with decks that aren't actually randomly shuffled or the magician has ways of forcing the participant to pick a certain card, so picking a card is deterministic, or picking the card is random but returning it to the deck is deterministic, and so it can easily be found by being out of position. If we drop a coin or a die only a short distance, it might not bounce much, so the result is strongly determined by the original state of the die. Much of the randomness of things like coin flips or dice rolls or lottery balls being removed from a hopper have to do with physics problems that could be considered deterministic if we understood all the variables, but the equations are so difficult that solving them completely is beyond even the most sophisticated computer simulations.
This brings us to random numbers and computers. A computer is completely deterministic. It cannot truly produce a random number, though every computer and even many calculators, including the TI-30XIIs, have random number generators. Here, the computer takes some input unknown to the user, puts it through a function also unknown to the user and produces an output. This is called pseudorandom, and debate over these methods continue to this day. One of the fathers of computer science, the great Hungarian mathematician John Von Neumann, was quoted as saying, "Anyone who considers arithmetical methods of producing random digits is, of course, in a state of sin." A computer has nothing but arithmetical methods available. The tests done to see if a method produces output that is sufficiently random have to do with a distributions of a large set of pseudorandom output.

The probability of r successes in n independent trials, where p is the probability of success of any given trial
The simplest kind of problem in multiple trials is to assume independence between the trials, that the probability of success remains constant over all the trials, and we call that probability p. A basic question in these kinds of experiments is to ask what is the probability of getting a specific number of successes, calling that number r, in a specific number of trials, a number we will call n. If you have a TI-83 or TI-84, there is a function in the distribution menu (blue button then DISTR) called binompdf, that takes as its input n, p and r in that order. On the TI-30XIIs, we have to type in a formula.
Example #1: If we flip a fair coin, p = .5, ten times, what is the probability of exactly 6 heads and 4 tails?
TI-83 or TI-84: Go to the distribution menu, select binompdf and type in the following values
binompdf(10,.5,6) = 0.205078125
On the TI-30xIIs, here is what to type in
10[prb][right arrow]6x.5^6x.5^4[enter]
It will read
10 nCr 6 * .5^6 * .5^4
0.205078125

A different question would be what are the chances of at most r successes in n trials. Again, the TI-83 and TI-84 have a single function solution, this one called binomcdf(n, p, r). On the TI-30XIIs, we either have to calculate all the separate values, from the probability of 0 successes up through the probability of r successes then add these up, or if this is too much work, there is a method using normal distribution to approximate binomial distribution.
If you have Java on your computer, you can go to this website to see how the numbers across a row of Pascal's Triangle look like the bell-shaped curve. We can use z-scores and the lookup table to get values that will approximate these probabilities, and the approxomations get better as the numbers get bigger.
Example #2: If we flip a fair coin, p = .5, ten times, what is the probability of at most 6 heads?
TI-83 or TI-84: Go to the distribution menu, select binomcdf and type in the following values
binompcf(10,.5,6) = 0.828125
On the TI-30XIIs:
This entails a lot of work, but not an impossible amount. We need to find
p(exactly 0 heads) + p(exactly 1 head) + p(exactly 2 heads) + p(exactly 3 heads) + p(exactly 4 heads) + p(exactly 5 heads) + p(exactly 6 heads) = 0.828125
We have the normal approximation method, but we will see when n = 10, it's not very good.
n = 10, p = .5, r = 6
z = (6 + .5 - .5*10)/sqrt(.5*.5*10) = .3
Lookup table: .3 -> .6179
The approximate value at around 62% is very far from the true value at nearly 83%.
Different books have different cut-off points, but at a minimum, using the normal approximation to binomial should only be used when both np > 5 and nq > 5. In this case, both values equal 5, so this would not be a good candidate for using this method.
Example #3: If we flip a fair coin, p = .5, one hundred times, what is the probability of at most 60 heads?
TI-83 or TI-84: Go to the distribution menu, select binomcdf and type in the following values
binompcf(100,.5,60) = 0.982399899891... ~= .9824
TI-30XIIs: It's too many things to add up, so the approximation method is our only hope. Both np > 5 and nq > 5, so we can move forward.
(60 + .5 - .5*100)/sqrt(.5 * .5 * 100) = 2.1
Lookup table: 2.1 -> .9821
When n=100, the approximation is not perfect, but it is very close, unlike the results when n=10.

Another question that could be asked is the probability of getting at least r successes in n trials. "At least r" is the complement of "At most r-1", which means the two probabilities will add up to one.
Example #4: If a 70% free throw shooter takes ten shots, p = .7, what is the probability she makes 8 shots or more?
On the TI-83 or TI-84:
1 - binomcdf(10, .7, 7) = .3827827864..., which rounds to .3828 to four places.
On the TI-30XIIs
10[prb][right arrow]8x.7^8x.3^2[enter]
It will read
10 nCr 8 * .7^8 * .3^2
0.233474441
10[prb][right arrow]9x.7^9x.3^1[enter]
It will read
10 nCr 9 * .7^9 * .3^1
0.121060821
10[prb][right arrow]10x.7^10x.3^0[enter]
It will read
10 nCr 10 * .7^10 * .3^0
0.028247525
If we round these numbers to five places, add them up and round the answer to four places, it should agree with the answer above.
.23347 + .12106 + .02825 = .38278, which rounds to .3828, which agrees with the above answer.
Example #4: If a 70% free throw shooter takes 100 shots, p = .7, what is the probability she makes 75 shots or more?
On the TI-83 or TI-84:
1 - binomcdf(100, .7, 74) = .163130104..., which rounds to .1631 to four places.
On the TI-30XIIs: The problem is adding up too many parts, but np = 70 and nq = 30, both of which are more than 5, so let's go to the approximation method.
z = (75 - .5 - 70)/sqrt(.7*.3*100) = .98198..., which rounds to .98
Lookup table: .98 -> .8365, and 1-.8365 = .1635, which again is pretty close to the actual answer.
It's common for people to use the word random in a casual manner, but in the field of the philosophy of science, discussion of whether something can be considered random or not is a subject of intense debate. The opposite of random is deterministic, which is to say that when we perform a task, we understand the possible outcomes thoroughly. For example, putting a key in a lock is a deterministic act. Will the door open? Not necessarily. It might be the wrong key. The key might be correct, but it might have worn out over time. A brand new key in a lock that has been used might have edges that are too sharp. The lock could malfunction. Maybe the person didn't turn the key in the right direction. So deterministic does not mean, "If you do a, then b will also happen." It can be more complicated than that. But in a completely deterministic act, we have an expected outcome, and even when it fails, we have explanations of why it fails.
The problem of determinism versus randomness is not a yes/no situation. We have some acts we consider random, like flipping a coin or rolling a die or choosing a card from a deck. If done under certain circumstances, even these can be deterministic. If the deck is removed from the pack and unshuffled, the top card will be the way the cards were sorted at the factory, and so it is completely deterministic. Some card tricks are done with decks that aren't actually randomly shuffled or the magician has ways of forcing the participant to pick a certain card, so picking a card is deterministic, or picking the card is random but returning it to the deck is deterministic, and so it can easily be found by being out of position. If we drop a coin or a die only a short distance, it might not bounce much, so the result is strongly determined by the original state of the die. Much of the randomness of things like coin flips or dice rolls or lottery balls being removed from a hopper have to do with physics problems that could be considered deterministic if we understood all the variables, but the equations are so difficult that solving them completely is beyond even the most sophisticated computer simulations.
This brings us to random numbers and computers. A computer is completely deterministic. It cannot truly produce a random number, though every computer and even many calculators, including the TI-30XIIs, have random number generators. Here, the computer takes some input unknown to the user, puts it through a function also unknown to the user and produces an output. This is called pseudorandom, and debate over these methods continue to this day. One of the fathers of computer science, the great Hungarian mathematician John Von Neumann, was quoted as saying, "Anyone who considers arithmetical methods of producing random digits is, of course, in a state of sin." A computer has nothing but arithmetical methods available. The tests done to see if a method produces output that is sufficiently random have to do with a distributions of a large set of pseudorandom output.

The probability of r successes in n independent trials, where p is the probability of success of any given trial
The simplest kind of problem in multiple trials is to assume independence between the trials, that the probability of success remains constant over all the trials, and we call that probability p. A basic question in these kinds of experiments is to ask what is the probability of getting a specific number of successes, calling that number r, in a specific number of trials, a number we will call n. If you have a TI-83 or TI-84, there is a function in the distribution menu (blue button then DISTR) called binompdf, that takes as its input n, p and r in that order. On the TI-30XIIs, we have to type in a formula.
Example #1: If we flip a fair coin, p = .5, ten times, what is the probability of exactly 6 heads and 4 tails?
TI-83 or TI-84: Go to the distribution menu, select binompdf and type in the following values
binompdf(10,.5,6) = 0.205078125
On the TI-30xIIs, here is what to type in
10[prb][right arrow]6x.5^6x.5^4[enter]
It will read
10 nCr 6 * .5^6 * .5^4
0.205078125

A different question would be what are the chances of at most r successes in n trials. Again, the TI-83 and TI-84 have a single function solution, this one called binomcdf(n, p, r). On the TI-30XIIs, we either have to calculate all the separate values, from the probability of 0 successes up through the probability of r successes then add these up, or if this is too much work, there is a method using normal distribution to approximate binomial distribution.
If you have Java on your computer, you can go to this website to see how the numbers across a row of Pascal's Triangle look like the bell-shaped curve. We can use z-scores and the lookup table to get values that will approximate these probabilities, and the approxomations get better as the numbers get bigger.
Example #2: If we flip a fair coin, p = .5, ten times, what is the probability of at most 6 heads?
TI-83 or TI-84: Go to the distribution menu, select binomcdf and type in the following values
binompcf(10,.5,6) = 0.828125
On the TI-30XIIs:
This entails a lot of work, but not an impossible amount. We need to find
p(exactly 0 heads) + p(exactly 1 head) + p(exactly 2 heads) + p(exactly 3 heads) + p(exactly 4 heads) + p(exactly 5 heads) + p(exactly 6 heads) = 0.828125
We have the normal approximation method, but we will see when n = 10, it's not very good.
n = 10, p = .5, r = 6
z = (6 + .5 - .5*10)/sqrt(.5*.5*10) = .3
Lookup table: .3 -> .6179
The approximate value at around 62% is very far from the true value at nearly 83%.
Different books have different cut-off points, but at a minimum, using the normal approximation to binomial should only be used when both np > 5 and nq > 5. In this case, both values equal 5, so this would not be a good candidate for using this method.
Example #3: If we flip a fair coin, p = .5, one hundred times, what is the probability of at most 60 heads?
TI-83 or TI-84: Go to the distribution menu, select binomcdf and type in the following values
binompcf(100,.5,60) = 0.982399899891... ~= .9824
TI-30XIIs: It's too many things to add up, so the approximation method is our only hope. Both np > 5 and nq > 5, so we can move forward.
(60 + .5 - .5*100)/sqrt(.5 * .5 * 100) = 2.1
Lookup table: 2.1 -> .9821
When n=100, the approximation is not perfect, but it is very close, unlike the results when n=10.

Another question that could be asked is the probability of getting at least r successes in n trials. "At least r" is the complement of "At most r-1", which means the two probabilities will add up to one.
Example #4: If a 70% free throw shooter takes ten shots, p = .7, what is the probability she makes 8 shots or more?
On the TI-83 or TI-84:
1 - binomcdf(10, .7, 7) = .3827827864..., which rounds to .3828 to four places.
On the TI-30XIIs
10[prb][right arrow]8x.7^8x.3^2[enter]
It will read
10 nCr 8 * .7^8 * .3^2
0.233474441
10[prb][right arrow]9x.7^9x.3^1[enter]
It will read
10 nCr 9 * .7^9 * .3^1
0.121060821
10[prb][right arrow]10x.7^10x.3^0[enter]
It will read
10 nCr 10 * .7^10 * .3^0
0.028247525
If we round these numbers to five places, add them up and round the answer to four places, it should agree with the answer above.
.23347 + .12106 + .02825 = .38278, which rounds to .3828, which agrees with the above answer.
Example #4: If a 70% free throw shooter takes 100 shots, p = .7, what is the probability she makes 75 shots or more?
On the TI-83 or TI-84:
1 - binomcdf(100, .7, 74) = .163130104..., which rounds to .1631 to four places.
On the TI-30XIIs: The problem is adding up too many parts, but np = 70 and nq = 30, both of which are more than 5, so let's go to the approximation method.
z = (75 - .5 - 70)/sqrt(.7*.3*100) = .98198..., which rounds to .98
Lookup table: .98 -> .8365, and 1-.8365 = .1635, which again is pretty close to the actual answer.
Tuesday, April 21, 2009
Class Notes for 4/20
We dealt with probability in a single instance earlier in the class when we had the relative frequencies of the values of categorical variables. Relative frequencies, listed in a population as p and in a sample as p-hat, are numbers between 0 and 1. If we take all the relative probabilities of all the values of a variable, they will add up to 1, or something very close to 1 depending on rounding error.
We will now talk about probability in multiple event experiments, like flipping ten coins or rolling five dice or drawing a hand of four cards from a 52 card deck. The first important split in the types of multiple event experiments is between independent and dependent events.
Events are independent if the probability of a later event does not change based on the result of an earlier event. For example, if I flip a coin that I can assume is fair, there is a 50% chance of heads and a 50% chance of tails every time I flip it. If by chance, the coin comes up heads ten times in a row, even though earlier testing had shown it to be a 50%-50% chance each time, the eleventh flip is still 50%-50%. Unusually long runs of all heads or all tails are rare, but they are not impossible. Flipping coins and rolling dice are typical examples of independent random events.
Events are dependent if the probability of a later event changes based on the result of an earlier event. The typical example of this is drawing cards from a shuffled deck. If the deck has 52 cards and 4 aces, the probability of drawing an ace from the deck is 4/52 = 1/13 ~= .0769...
If the card has been drawn, what is the probability of the second card being an ace? That depends on what the first card is. If the first card is an ace, there are only 3 left in the deck, which now has 51 cards, so the probability is 3/51 = 1/17 ~= .0588..., which is a lower probability than getting an ace the first card.
If the first card wasn't an ace, the odds are 4/51, ~= .0784..., a slightly higher probability than drawing an ace the first time.
If I say someone is a 70% free throw shooter, is every free throw attempt independent of what happened before? Often, we set up such an experiment assuming independence just to make our work simpler, but the human factor is involved, so in reality it's very likely to be dependent. Some people get frustrated after a few misses and will do worse. Others will learn from the mistakes of a few misses and figure out what they are doing wrong and make improvements. A player might be having a bad day for some reason, or might instead have excellent concentration or just really good luck that day. But again, these kinds of experiments are often set up as though each free throw trial is independent of what came before.
Let's look at flipping coins. A list of all possible events is called the event space. Here are some examples of event spaces.
Event space for flipping one coin
Heads (H)
Tails (T)
ways to get one head = 1
ways to get no heads = 1
Event space for flipping two coins
HH
HT
TH
TT
ways to get two heads = 1
ways to get one head = 2
ways to get no heads = 1
Event space for flipping three coins
HHH
HHT
HTH
HTT
THH
THT
TTH
TTT
ways to get three heads = 1
ways to get two heads = 3
ways to get one head = 3
ways to get no heads = 1

The list of numbers of ways to get r successes in n trials is often written in the pattern of the picture shown here, and this pattern is called Pascal's Triangle, at least in most of the world. The Italians call it Tartaglia's Triangle and the Chinese call it Yanghui's Triangle. None of these people actually invented it or claimed to have invented it. It's been around since before the time of Christ, and it has been studied all around the world.
While it is very common to see it presented in the form here as an equilateral triangle, it can also be presented where the first numbers in each row are lined up straight as follows
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
... etc.
It is standard to start counting the top row as row 0, and the left most column as column 0. For example, the 6 we see in the middle of the last row I typed in is row 4, column 2. Instead of having a copy of Pascal's Triangle around, our calculators have these numbers available. On Texas Instruments calculators, the function is under the probability menu. On the TI-30XIIs, the way to get that 6 is to type
4 [prb][right arrow]2[enter]
The calculator will read
4 nCr 2
6
All scientific calculators should have this function available, but all of them are slightly different. The TI-89 writes it as nCr(4,2) and Casio calculators write it as 4 C 2. I will pronounce it "4 choose 2", and when I type on the blog, I will type C(4,2). When I write it on the board or on tests, I will put a 4 on top of a 2 and surround both numbers with a large parentheses. These numbers are called the binomial coefficients.
The formula for finding the probability for exactly r successes in n independent trials where the probability of success on any single trial is p is shown here. In some books, they don't use the letter q, instead replacing it with (1-p). Likewise, sometimes w is replaced with (n-r). I use the extra letters and include the relationships between them. The letters r and w stand for right and wrong. The letter p and q are standard in probability texts for the probability of a success or a failure.
Let's do an example. You are given a four question multiple choice test, each question having five possible answers. The test is given in a language you do not read, so all you can do is guess. Each question is independent from the others, meaning that if C is the right answer to the first question, it's also possibly the answer to the second. The probability p of a correct guess is 1 chance in 5, or .2, The probability of failure q is 1-.2 = .8, and of course p + q = 1.
Probability of no correct answers = C(4,0)*.2^0*.8^4 = .4096
Probability of exactly one correct answer = C(4,1)*.2^1*.8^3 = .4096
Probability of exactly two correct answers = C(4,2)*.2^2*.8^2 = .1536
Probability of exactly three correct answers = C(4,3)*.2^3*.8^1 = .0256
Probability of four correct answers = C(4,4)*.2^4*.8^0 = .0016
The expected value of correct answers is n*p, so in this case it's 4*.2 = .8, which isn't possible. You can't get a fraction of correct answers on a multiple choice test. The expected value in this case says that over the long run, a test like this should average .8 right answers out of four. As we can see, the most likely thing to happen is actually a tie for first, where getting either no answers right or one answer right both have a probability of about 41%. If you need to get three answers right to pass the test, the odds are less than 3% to get either three or four right, and the odds of getting everything right by chance is a very slim 16 chances in 10,000.
If you have a TI-83 or TI-84, there is a function under the distribution menu called binompdf(n,p,r). All you have to is enter the function, then the three values in the order given, separated by commas.
The function for three right in four trials with probability .2 at each trial is binompdf(4, .2, 3), which as we see above is .0256.
Practice problem.
The test is changed. There are now five multiple choice questions and four choices for each, but it is still given in a language you do not read.
Round the probabilities to four places after the decimal.
1. What is the expected value?
2. What is the probability of no correct answers?
3. What is the probability of exactly one correct answer?
4. What is the probability of exactly two correct answers?
5. What is the probability of exactly three correct answers?
6. What is the probability of exactly four correct answers?
7. What is the probability of five correct answers?
Answers in the comments.
We will now talk about probability in multiple event experiments, like flipping ten coins or rolling five dice or drawing a hand of four cards from a 52 card deck. The first important split in the types of multiple event experiments is between independent and dependent events.
Events are independent if the probability of a later event does not change based on the result of an earlier event. For example, if I flip a coin that I can assume is fair, there is a 50% chance of heads and a 50% chance of tails every time I flip it. If by chance, the coin comes up heads ten times in a row, even though earlier testing had shown it to be a 50%-50% chance each time, the eleventh flip is still 50%-50%. Unusually long runs of all heads or all tails are rare, but they are not impossible. Flipping coins and rolling dice are typical examples of independent random events.
Events are dependent if the probability of a later event changes based on the result of an earlier event. The typical example of this is drawing cards from a shuffled deck. If the deck has 52 cards and 4 aces, the probability of drawing an ace from the deck is 4/52 = 1/13 ~= .0769...
If the card has been drawn, what is the probability of the second card being an ace? That depends on what the first card is. If the first card is an ace, there are only 3 left in the deck, which now has 51 cards, so the probability is 3/51 = 1/17 ~= .0588..., which is a lower probability than getting an ace the first card.
If the first card wasn't an ace, the odds are 4/51, ~= .0784..., a slightly higher probability than drawing an ace the first time.
If I say someone is a 70% free throw shooter, is every free throw attempt independent of what happened before? Often, we set up such an experiment assuming independence just to make our work simpler, but the human factor is involved, so in reality it's very likely to be dependent. Some people get frustrated after a few misses and will do worse. Others will learn from the mistakes of a few misses and figure out what they are doing wrong and make improvements. A player might be having a bad day for some reason, or might instead have excellent concentration or just really good luck that day. But again, these kinds of experiments are often set up as though each free throw trial is independent of what came before.
Let's look at flipping coins. A list of all possible events is called the event space. Here are some examples of event spaces.
Event space for flipping one coin
Heads (H)
Tails (T)
ways to get one head = 1
ways to get no heads = 1
Event space for flipping two coins
HH
HT
TH
TT
ways to get two heads = 1
ways to get one head = 2
ways to get no heads = 1
Event space for flipping three coins
HHH
HHT
HTH
HTT
THH
THT
TTH
TTT
ways to get three heads = 1
ways to get two heads = 3
ways to get one head = 3
ways to get no heads = 1

The list of numbers of ways to get r successes in n trials is often written in the pattern of the picture shown here, and this pattern is called Pascal's Triangle, at least in most of the world. The Italians call it Tartaglia's Triangle and the Chinese call it Yanghui's Triangle. None of these people actually invented it or claimed to have invented it. It's been around since before the time of Christ, and it has been studied all around the world.
While it is very common to see it presented in the form here as an equilateral triangle, it can also be presented where the first numbers in each row are lined up straight as follows
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
... etc.
It is standard to start counting the top row as row 0, and the left most column as column 0. For example, the 6 we see in the middle of the last row I typed in is row 4, column 2. Instead of having a copy of Pascal's Triangle around, our calculators have these numbers available. On Texas Instruments calculators, the function is under the probability menu. On the TI-30XIIs, the way to get that 6 is to type
4 [prb][right arrow]2[enter]
The calculator will read
4 nCr 2
6
All scientific calculators should have this function available, but all of them are slightly different. The TI-89 writes it as nCr(4,2) and Casio calculators write it as 4 C 2. I will pronounce it "4 choose 2", and when I type on the blog, I will type C(4,2). When I write it on the board or on tests, I will put a 4 on top of a 2 and surround both numbers with a large parentheses. These numbers are called the binomial coefficients.
The formula for finding the probability for exactly r successes in n independent trials where the probability of success on any single trial is p is shown here. In some books, they don't use the letter q, instead replacing it with (1-p). Likewise, sometimes w is replaced with (n-r). I use the extra letters and include the relationships between them. The letters r and w stand for right and wrong. The letter p and q are standard in probability texts for the probability of a success or a failure.Let's do an example. You are given a four question multiple choice test, each question having five possible answers. The test is given in a language you do not read, so all you can do is guess. Each question is independent from the others, meaning that if C is the right answer to the first question, it's also possibly the answer to the second. The probability p of a correct guess is 1 chance in 5, or .2, The probability of failure q is 1-.2 = .8, and of course p + q = 1.
Probability of no correct answers = C(4,0)*.2^0*.8^4 = .4096
Probability of exactly one correct answer = C(4,1)*.2^1*.8^3 = .4096
Probability of exactly two correct answers = C(4,2)*.2^2*.8^2 = .1536
Probability of exactly three correct answers = C(4,3)*.2^3*.8^1 = .0256
Probability of four correct answers = C(4,4)*.2^4*.8^0 = .0016
The expected value of correct answers is n*p, so in this case it's 4*.2 = .8, which isn't possible. You can't get a fraction of correct answers on a multiple choice test. The expected value in this case says that over the long run, a test like this should average .8 right answers out of four. As we can see, the most likely thing to happen is actually a tie for first, where getting either no answers right or one answer right both have a probability of about 41%. If you need to get three answers right to pass the test, the odds are less than 3% to get either three or four right, and the odds of getting everything right by chance is a very slim 16 chances in 10,000.
If you have a TI-83 or TI-84, there is a function under the distribution menu called binompdf(n,p,r). All you have to is enter the function, then the three values in the order given, separated by commas.
The function for three right in four trials with probability .2 at each trial is binompdf(4, .2, 3), which as we see above is .0256.
Practice problem.
The test is changed. There are now five multiple choice questions and four choices for each, but it is still given in a language you do not read.
Round the probabilities to four places after the decimal.
1. What is the expected value?
2. What is the probability of no correct answers?
3. What is the probability of exactly one correct answer?
4. What is the probability of exactly two correct answers?
5. What is the probability of exactly three correct answers?
6. What is the probability of exactly four correct answers?
7. What is the probability of five correct answers?
Answers in the comments.
Subscribe to:
Posts (Atom)
