Question
This is all in an R markdown file. I honestly have no time to do all of this and need help. Nothing I have done
This is all in an R markdown file. I honestly have no time to do all of this and need help. Nothing I have done works at all. This is the plain file we were given to start with no changes or edits to it. Please I am desperate.
```{r echo=FALSE} options(scipen=999) # turns off scientific notation options(digits=4) # rounds to 4 digits set.seed( 0 ) # set your own seed! ```
Suppose you have a standard, fair, 6-sided die. Youre going to roll it again and again until all 6 sides have come up at least once. How long will this take, on average? More generally, if you have a fair k-sided die (or cards marked 1 through k that youre sampling with replacement), whats the expected number of tries required to see all k numbers?
Your simulator function should have one input: k = the number of sides on your die. This function should have one output: a single value of the random variable X = number of rolls required to see all k sides.
Your iterator function should have two inputs: k from before and n = number of iterations. The output should be a vector of n simulated values of X.
I strongly suggest you read the entire project before beginning to write your code! In particular, you might consider how to make your code flexible enough to handle Question 7.
```{r echo=TRUE}
```
Use your function to answer the following questions. NOTE: You should only run your main function *once* to answer questions 1-3. Don't re-run it for each question!
### 1. Assume k = 6. Create a well-labeled histogram of at least 10,000 values of the variable X = number of rolls to see all k sides. Describe the distribution (shape, center, spread).
```{r}
```
### 2. Construct and interpret in context a 95% confidence interval for the expected value of X when k = 6.
```{r}
```
### 3. Construct and interpret in context a 95% prediction interval for a single future value of X when k = 6.
```{r}
```
Now youre going to investigate how the mean of X grows with k. Is the mean of X something like 2k? 3k? k^2^?
### 4. Run your function for k = 1, 5, 10, 20, 30, 40, 50, and 60 (with just n=1000 for each k; otherwise, it'll take a really long time). For each run of 1000, record the sample mean $\bar{x}$. You will need those eight $\bar{x}$ values for Question 5.
```{r}
```
### 5. For k = 1, 5, ... , 60, plot $(\bar{x}\div k)$ versus k, with $(\bar{x}\div k)$ on the vertical axis and k on the horizontal axis.
If you use the `plot` function in R with the option `type="l"`, you should get a graph with your eight $(k,\bar{x}\div k)$ points connected by line segments. That's what I want.
```{r}
```
A plot like the one you just made can help us understand the growth rate of the mean of X. For example, if the mean grows linearly with k (like 2k or 3k), then $(\bar{x}\div k)$ is a constant and your graph should be essentially flat. On the other hand, if the mean is quadratic in k, then $(\bar{x}\div k)$ should be roughly linear.
### 6. Based on your plot, make an educated guess about an expression for E(X) as a function of k. Explain how your graph supports your answer.
The last two questions will require either modifying your original function or writing a new one.
### 7. Define Y = the number of rolls of a fair six-sided die required to see all six sides at least **twice**. Repeat 1-3 for the random variable Y.
```{r}
```
### 8. Is the mean of Y roughly twice the mean of X? Should it be? Why or why not?
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