Question
Please use R. Create the vectordie
Please use R.
Create the vectordie <- 1:6, and simulate 10, 20, 30, ..., 990, 1000 tosses of a fair die.
Calculate the proportion of times in which you got number 4 in each of the 100 cases (whenn=10,20,30,...,990,1000
n=10, 20, 30, ..., 990, 1000). Store these 100 values in a vector.
Create data frame containing the vector of proportions, along with the number of tosses.
Using ggplot2 andgeom_line()as geometry (or the base R plotting functions settingtype='l'), plot the 100 estimates againstnto show that, asn
nincreases, the proportion of 4 stabilizes around the true probability of obtaining 4, i.e.1/6. Usegeom_hline()(orabline()if using base R) to add a red dashed horizontal line wherey=1/6
y=1/6(type?geom_hlineif you have not used this function before).
Before you start coding, setset.seed(7).
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