Problem 3
For this problem, we will use R to simulate the probability of
getting a pair (i.e., two of the same card) when you draw two cards
from a deck without replacement. Create a function that inputs n,
the number of trials, and outputs the probability based on those n
trials that a pair was drawn. Calculate the probabilities using n =
100,1000,10000, and compare that to the true probability (which you
have to calculate). Set your seed to 1001 using set.seed(1001)
before running your function,i.e.
set.seed(1001) yourfunctionname(10) yourfunctionname(1000)
yourfunctionname(10000)
Problem 4
In this problem we will use R to simulate a biased coin ?ip. In
each trial, you select one of three colored coins (Blue, Red, and
Green) with equal probability, and then ?ip the coin. The Red coin
has a 40% chance of landing heads, the Blue coin has a 70% chance,
and the Green coin is a fair coin. Create a program which takes in
n, the number of trials, and outputs the following probabilities:
Let A be the event that the blue coin was selected. Let B be the
event that the coin ?ip resulted in a head.
(a) P(A)
(b) P(B) (c) P(A?B) (d) P(AC ?B) (e) P(A?B) (f) P(A|B) (g)
P(A|BC) Report each probability for n = 100, and 100000. Again set
your seed to 1001 before running this function. Hint: An outline of
your program could look like the following: Step 1: Record the
color of the coin selected for n trials. Step 2: For each of the n
trials, based on the color of the coin, assign the appropriate
probabilities and ?ip the coin. (You should now have 2 vectors, one
that has recorded color, and one which has recorded head/tail).
Step 3: Use logical arguments to calculate the probabilities above.
Step 4: Output the appropriate probabilities.





