{rtf1ansiansicpg1252deff0deflang1033deflangfe1033{fonttbl{f0fmodernfcharset0 CourierNewPS-BoldMT;}{f1fmodernfcharset0 CourierNewPSMT;}{f2fmodernfcharset0 CourierNewPS-BoldItalicMT;}}
{*generator Msftedit 5.41.15.1515;}viewkind4uc1pardnowidctlpartx720tx1440tx2160tx2880tx3600tx4320tx5040tx5760tx6480tx7200tx7920tx8640bf0fs24 #11(c)b0f1par
par
bif2 #(i)b0i0f1par
bif2 # Generate a standard deck of 52 playing cards as a matrix:b0i0f1par
par
faces = c(“Jack”, “Queen”, “King”)par
value = c(“Ace”, 2:10, faces)par
suit = c(“Clubs”, “Diamonds”, “Hearts”, “Spades”)par
par
deck = NULLpar
for (i in 1:4) par
for (j in 1:13) par
deck = rbind(deck, c(value[j], suit[i]))par
deck = matrix(deck, nr=52, nc=2, dimnames = list(NULL, c(“Value”, “Suit”)))par
par
bif2 # To see the entire deck, type the word b0i0f1 deckbif2 on a new par
# command line, and hit Return. (Not required to submit.)b0i0f1par
par
pardnowidctlparri-90tx720tx1440tx2160tx2880tx3600tx4320tx5040tx5760tx6480tx7200tx7920tx8640 #________________________________________________________________par
pardnowidctlpartx720tx1440tx2160tx2880tx3600tx4320tx5040tx5760tx6480tx7200tx7920tx8640par
bif2 #(ii)par
# Perform the experiment by manually running the code below par
# N = 10 times. Each time, it randomly selects and displays par
# four cards, prints “TRUE” if face card(s) present, else par
# prints “FALSE”:par
b0i0f1par
cards = deck[sample(1:52, 4, replace = F), ]par
cardspar
any(cards[, 1] %in% faces)par
par
bif2 # Submit this output. Also, compute the proportion of TRUEs.par
# How close is this statistic to the actual probability?b0i0f1par
par
#_______________________________________________________________par
par
bif2 #(iii)par
# The code below runs N = 1000 simulations of this experiment, par
# and computes and displays the number of TRUES and FALSES.b0i0f1 par
par
N = 1000tabtabbi # You can make N bigger, if desired.par
b0i0 TRUES = 0par
FALSES = 0par
par
for (i in 1:N) {par
cards = deck[sample(1:52, 4, replace = F), ] par
if (any(cards[, 1] %in% faces) == T) TRUES = TRUES + 1 }par
FALSES = N – TRUES par
par
TRUESpar
FALSESpar
par
bif2 # How close is this proportion of TRUES for N = 1000 to the par
# actual probability? How does this compare with N = 10?par
par
# A sample-based estimator (such as proportion here) that par
# converges (or more precisely, “converges in probability”)par
# to its intended population parameter as N becomes infinite, par
# is said to be a “consistent” estimator of that parameter.b0i0f1 par
}
This was the rcode for this problem you can see the question in the picture that i uplode you just need to finish the third question.
0 comments