This year`s test with solutions

Second Test
CSCI2244-Randomness and Computation
April 15, 2015
The Jarndyce Jujube and Jellybean Company manufactured colorful candies
in giant jars.
1
1
Jellybean Poker
(You should write the answers to these questions as formulas. Your formulas can
(but do not have to) include binomial coefficients, exponential functions, unevaluated sums, products and powers. The actual numerical answers are given with the
problem.)
When the Jarndyce company was founded in 1914, its only product was a jar
containing three hundred jellybeans, with 100 each of red, green and blue beans.
(a) You reach in the jar and pull out three jellybeans. What is the probability that
they all have different colors? (The numerical answer is 0.2245.)
Solution. There areseveral ways to get the answer. The total number of 3-element
sets of beans is 300
and there are 10 choices for the red bean, 10 for the blue and
3
10 for the green, giving the probability:
103
.
300
3
Another approach is to view the problem as a sequence of three choices: Any
of the 300 jellybeans will do for the first choice. At the second choice, there are
200 left of a different color out of the 299 beans remaining in the jar, and at the
third choice, there are only 100 left of a third color out of 298 remaining. So the
answer is:
200 100
×
.
299 298
Yes, the two answers are the same! The second answer also shows you that the
probability is approximately 29 = 0.222, which agrees with the numerical result
given above.
(b) You reach the jar and pull out ten jellybeans. What is the probability that you
get exactly four red jellybeans and six green jellybeans? (The numerical answer
is 0.00334.)
300
Solution. We have the denominator
as the total number of 10-jellybean
10
100
selections. There are 4 ways to choose the four reds and 100
ways to choose
6
the 6 greens, so the probability is
2
100
6
100
4
·
300
10
2
.
The Red Jellybean Craze of 2011
(Once again, this question is to be answered with unevaluated formulas, as in
Problem 1.)
In 2011, the company began marketing enormous jars one meter tall, each
containing one million (106 ) jellybeans. They also decreased the proportion of
red jellybeans to just 1% of the total. (That is, a jar typically contained 10,000 red
jellybeans.) This created a secondary market in red jellybeans, which were sold
on the Internet for ever-increasing prices.
If you reach into one of these jars and pull out 100 jellybeans, what is the
probability that exactly 3 of them are red? Give three answers to this question:
(a) Write an expression that gives the answer exactly, recognizing that this is a
problem about sampling without replacement. (Answer: 0.060996.)
Solution. This is in essence identical to problem 1(b). The solution is
104
3
6 −104
· 10 97
106
100
.
(b) Write an expression that is easier to compute, treating this as a problem about
sampling with replacement, where the 100 jellybeans are sampled one by one and
thrown back into the jar before the next one is removed. (Answer: 0.060999.)
Solution. (Note the typo in the original version of the problem, where 100 appeared as 50.) When we do sampling with replacement we are treating the problem as 100 successive coin tosses of a coin that comes up heads 1% of the time.
The probability of 3 heads is given by the binomial distribution.
100
· 0.013 · 0.9997 .
3
3
(c) Now write an even easier-to-compute expression involving the exponential
function that gives a reasonable approximation to the probability in (b). (Answer:
0.0613.)
Solution. The binomial distribution with large n and small p is well-approximated
by the Poisson distribution with λ = np = 100 × 0.01 = 1. So the probability is
approximately
1
λ3 −λ
·e = .
3!
6e
By the way, you can do a quick mental check that this more or less agrees with
the numerical answer given above. The constant e is between 2.5 and 3, so the
1
1
1
1
value 6e
is between 18
and 15
. It’s not too hard to calculate 18
= 0.0555.. and
1
= 0.0625, so we are in the correct range.
15
3
The Dark Side
(For part (a), you can again give an unevaluated formula, but for (b) you should
give the exact numerical answer. In each case you should either show your calculations or justify your conclusions on the basis of a result we studied in the
class.)
At the height of the craze, it was common to see a bleary-eyed young man frantically reaching into the jar, repeatedly pulling out jellybeans and stuffing them
into his mouth until he found a red one, which he put in his pocket to sell. Given
that there are so many jellybeans in the jar, we may still treat this as a problem of
sampling with replacement.
(a) What is the probability that he will eat more than four jellybeans in his search
for a red one? (Answer: 0.951.)
Solution. The probability that he will eat more than four jellybeans is the probability that the search will require more than 5 rounds. The probability that number
of rounds is exactly k is geometrically distributed (given the assumption of sampling with replacement) and is given by:
0.99k−1 · 0.01.
Thus the probability that the game lasts strictly more than 5 rounds is (using
the complementary probability)
4
1 − 0.01
4
X
0.99k .
k=0
We can also write the probability as the infinite sum
0.01 ·
∞
X
0.99k .
k=5
That’s all you have to do. But it’s worth noting that the last formulation lets
you calculate a back-of-the envelope estimate of the probability, provided you
remember how to sum an infinite geometric series, or simply use the fact that the
sum of the probabilities over all k is 1:
∞
X
0.99k = 100,
k=0
so
0.01 ·
∞
X
0.99k = 0.01 · 0.995 × 100 = 0.995 .
k=5
5
Furthermore, 0.99 = (1 − 0.01)5 ≈ 1 − 5 × 0.01 = 0.95.
(b) What is the average number of jellybeans that such a person eats before finding
a red one?
Solution. The expected value of a geometrically distributed random variable with
success probability p is 1/p. In this case p = 0.01, so the expected value of the
number of rounds to success is 100. This means that the average number of jellybeans eaten is 99.
4
The Bubble Bursts
In 2014 a group of counterfeiters began manufacturing imitations of the Jarndyce
Giant Jars in which 3% of the million jellybeans were red. As news of the scam
spread, the market for red jellybeans collapsed, and, on the one-hundredth anniversary of its founding, the Jarndyce company went bankrupt.
Just before the crash, it was estimated that one-quarter (0.25) of the jars on the
market were counterfeits. I reach into a jar, not knowing if it is genuine or fake,
5
and pull out 100 jellybeans. Three of them are red. What is the probability that
the jar I chose was one of the fakes? In your solution, you should set out all the
events and conditional probabilities carefully.
To make the notation simpler, you should use p to denote the probability that
a selection of 100 jellybeans from a genuine jar contains exactly three red jellybeans, and use q to denote the corresponding probability for the fake. (The value
of p was computed in 2(a) and the value of q would be computed by the same
method, but you do not have to show this work. The numerical answer is 0.5541.))
Solution. We will use the p and q to denote the probabilities described above. The
events in question are:
• E: Your selection contains exactly three jellybeans
• Ffake : You selected the counterfeit jar
• Freal : You selected the real jar
We have p = P [E|Freal ] and q = P [E|Ffake ]. The problem asks for P [Ffake |E].
By Bayes’s Theorem,
P [Ffake |E] =
P [E|Ffake ] · P [Ffake ]
.
P [E]
The numerator is 0.25q. The denominator is
P [E] = P [E ∩ Ffake ] + P [E ∩ Freal ]
= P [E|Ffake ] · P [Ffake ] + P [E|Freal ] · P [Freal ]
= 0.25q + 0.75p.
So the answer is
0.25q
.
0.25q + 0.75p
6
5
A Troubling Discovery
(In both parts of this problem, you should give the exact numerical answer.)
Just this year, a young Candyologist at Skittles State University began reading
descriptions of the many sad cases described in Problem 3. She concluded that the
afflicted individuals had eaten far more jellybeans than the statistical prediction of
3(b). She published a paper with a theory that purported to explain why.
A giant jellybean jar, she wrote, does not have the red jellybeans distributed
uniformly among the others. Instead, due to slight differences in the weights of
the beans, the red ones tend to be more concentrated toward the bottom of the jar.
In fact, she was more precise than this: Let X be the random variable representing the depth, in meters, of a red jellybean selected uniformly at random from
those that are packed into a jar. Then the density function of X is approximately
p(x) = 3x2
where x varies between 0 and 1.
A typical abuser, she said, only picked jellybeans at random from the top half
of the jar, because they could not reach down any farther.
((a) Given this new information, find the proportion of red jellybeans that are in
the top half of the jar, and give a new estimate of the second answer to Problem
3(b).
Solution. The probability that a red jellybean is in the top half of the jar is (see
figure):
Z
0
1
2
1
2
1
3x dx = x = .
8
0
2
3
Thus there are approximately 10000/8=1250 red jellybeans in the top half of the
jar, out of a total of 500,000 jellybeans in the top half. So the probability of
picking a red jellybean if you only sample the top half is
1250
1
=
,
500000
400
and thus the corrected answer to 3(b) is 399.
(b) What is the average depth of a red jellybean?
7
8
This just asks for the expected value of X.
Z
E(X) =
0
1
1
3
3x3 = .
x · 3x dx =
4 0 4
2
9