Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

3. l[A problem via counting and simulation]] In a standard deck of 52 playing ca

ID: 3070653 • Letter: 3

Question

3. l[A problem via counting and simulation]] In a standard deck of 52 playing cards8, let's consider a new kind of hand:{ say a hand has no missing suits if it contains at least one card of each suit (a) If you are dealt a random 5 card hand (that is, a random subset of 5 cards chosen from the 52-card deck), what is the probability that it will have no missing suits? [Don't just write an answer, but try to include a systematic explanation of your reasoning in applying the fundamental counting principle.]] (b) What if you are dealt a random 6 card hand? IThe way I am imagining you will do this, (b) will be a bit more complicated than (a) because there are two cases in (b). That's ok, to count the total, you can count the two cases separately and add them up.] (c) Use R to perform simulations to approximate the probabilities from parts (a) and (b). Also do the same for 13 card handsthe simulation is no harder than for 5 or 6 cards, illustrating how simulation can enable us to answer questions that we might not be able to answer mathematically [Hints: There are typically lots of ways to code simulations depending on how you think of representing the problem through objects that can be created in R. Here is one thought in case you find it helpful. We want to sample from a deck and see what suits we get. For that question, the ranks are irrelevant, so if we simply denote the suits by 1, 2, 3, and 4, we can create a nice "deck" that is sufficient for the purposes of this problem simply as a vector of 13 1's, 13 2's, 13 3's and 13 4's, and sample our 5 cards (or 6 or 13 cards) from that vector (without replacement). You could create that simple deck vector by hand, or more elegantly using the rep function.]

Explanation / Answer

You can follow the hint given in the question. It is the easiest way to simulate.

First create an object called 'deck' which has 52 cards using code -

> deck <- c(rep(1:4,13))

If you read the data stored in this object, you would get the output as -

> deck

[1] 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4

----------------

Note that there are 52 values stored which include 13 of all 1,2,3 and 4. We are doing so because as mentioned in the hint, the heirarchy within suits doesn't matter in the question. So, we can assume that all the 13 cards within each suit have same rank. And thus 13 of each 1,2,3 and 4.

------------------

Now, we need to select a given number of cards from these 52 cards. So, we can use 'sample' function here. And for simulation purpose we use the 'replicate' function.

For hand of 5 cards -

First create the function for reading the number of distinct suits in hand as -

> hands <- function(){
+ suit <- sample(deck, size = 5, replace = FALSE, prob = NULL)
+ return(length(unique(suit)))
+ }

Now, use the following code to replicate -

> sim1 <- c(replicate(n=1000, expr = hands()))

Then calculate the probability of those having values of 4 using -

> prob = table(sim1)/length(sim1)

Then you can read the output as -

> prob
sim1
1 2 3 4
0.002 0.150 0.595 0.253

Hence, the required probability = 0.253.

Note that this can change for you as its random sampling.

-----------------------

Similarly for hand of 6, use the following code -

> hands2 <- function(){
+ suit <- sample(deck, size = 6, replace = FALSE, prob = NULL)
+ return(length(unique(suit)))
+ }
> sim2 <- c(replicate(n=1000, expr = hands2()))
> prob2 = table(sim2)/length(sim2)
> prob2
sim2
2 3 4
0.067 0.548 0.385

Thus, the probability here = 0.385

--------------------------------------------------------------

And for hand of 13 cards, use the following code -

> hands3 <- function(){
+ suit <- sample(deck, size = 13, replace = FALSE, prob = NULL)
+ return(length(unique(suit)))
+ }
> sim3 <- c(replicate(n=1000, expr = hands3()))
> prob3 = table(sim3)/length(sim3)
> prob3
sim3
3 4
0.042 0.958

So, the required probability = 0.958.

________________________________________--

Please ask if you have any doubt.

Note - I have used a sample size of n = 1000 for simulation. You can change it to 10000 or any higher value as per your wish.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote