A colorblind man is trying to put together a bouquet of 5 roses for his wife. He
ID: 3329932 • Letter: A
Question
A colorblind man is trying to put together a bouquet of 5 roses for his wife. He can choose from a total of 15 roses where 7 are red and 8 are white. Due to his colorblindness, the husband is picking the roses at random with each rose having an equal chance of being selected for the bouquet. Let the random variable Y denote the number of red roses in the bouquet. Use R to simulate the probability distribution of Y. Provide this result in two forms: (1) a table with each possible outcome and the associated Monte-Carlo estimate of probability (the simulated probability) and (2) a histogram
What R code should I use for this?
Explanation / Answer
Let Y denotes the number of red roses in the bouquet.
Thus Y can take values 0,1,2,3,4,5.
Just run the code below:
set.seed(1001)
n=5000
count <- numeric(n)
for(i in 1:n){
rand <- sample(1:15,5,replace = FALSE)
count[i] <- length(which(rand<=7))
}
t <- table(count)
t <- t/n
t #Emperical probabilities
hist(count,breaks = 6)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.