Question: Should be done in RStudio 3. Read in the file deck.csv, which we will use to simulate drawing cards from a deck. (check the demonstration

Should be done in RStudio

3. Read in the file deck.csv, which we will use to simulate drawing cards from a deck.

(check the demonstration sample code below for a related example)

(a) Simulate drawing two cards (without replacement) 5 times and print out the hand each

time.

(b) Simulate drawing a hand of two cards 100,000 times to estimate the probability of

drawing a pair (two cards with the same face).

(c) Simulate drawing a hand of five cards (without replacement) 100,000 times to estimate

the probability of drawing a flush (all suits are the same)

(Hint: use length(unique(hand $ suit)) to measure the number of different suits in hand)

Sample Code

deck = read.csv("deck.csv")

reps =3

numPairs = 0

for(i in 1:reps){

index = sample(1:52,size=5,replace = FALSE)

hand = deck[index,]

print(hand)

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!