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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started