Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This is a R Studio question. # Flip a coin three times, heads is 1, tails is zero flips = sample(x = C(O. 1), size
This is a R Studio question.
# Flip a coin three times, heads is 1, tails is zero flips = sample(x = C(O. 1), size = 3, replace = T) # Calculate the number of times it landed heads sum_flips = sum(flips) # If it landed on heads more than zero times execute the code in brackets if (sum_flips > 0) { # Roll die sum_flips times rolls sample(1:6, size = sum_flips, replace # Add up the different rolls sum_rolls = sum(rolls) } else { # If it didn't land on heads, let sum_flips be zero sum_rolls = 0 } # Store sum_flips and sum_rolls in a data set sim_results data.frame(sum_flips, sum_rolls) T) Modify the code using a for-loop to simulate that process 100,000 times. (a) Use the results to approximate the answers to question 4. In other words, using the results of your simulation, nd an approximation of the following probabilities if the sum of the rolls of the dice add up to four. i. Probability that the coin landed on heads once ii. Probability that the coin landed on heads twice iii. Probability that the coin landed on heads three times iv. Expected value of the number of times the coin landed on heads. (1)) Now approximate the same values if the rolls of the dice added up to twelve instead of fourStep 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