In: Statistics and Probability
Suppose n different cards are contained in a bag. You pick at card at random, observe which one you picked, and place it in the bag. This procedure is repeated until you draw a card that you drew previously: let X be the total number of times you pick a card. Using R (or an R function) estimate, via simulation, P(X > 10) for the case where n = 30. Need the R code for this without using monte carlo but basic r functions.
OUTPUT:
HERE ACTUAL PROBABILITY IS GIVEN BY THE EVENT >
TO GET 10 DIFFERENT CARD IN FIRST 10 DRAWS i.e
solving this gives 0.1846
and simulating it over sample ans of required probability is obtained as 0.1851
R CODE:
a<-c(1:30)
b<-c(21:30)
b<-b/30
print(prod(b))
count<-0
num<-100000
for (i in 1:num)
{
d<-sample(a,10,replace =TRUE)
d<-sort(d)
e<-c(0,d)
e<-e[-11]
if(sum((d-e)==0)>0)
count<-count+1
}
print(1-count/num)
#OVER
PLEASE RATE THE ANSWER BY THUMBS UP IF YOU LIKED THE SOLUTION.
THANKS for asking the problem