Question

In: Statistics and Probability

R Programming Exercise 3.4 From a normal distribution which has a standard deviation of 40 and...

R Programming Exercise 3.4

From a normal distribution which has a standard deviation of 40 and mean of 10, generate 2 to 600 samples. After generating the samples utilize the plot command to plot the mean of the generated sample (x-axis) against the number of samples (Y-axis). Use proper axis labels. Create a second plot of the density of the 600 samples that you generated.

Use adequate comments to explain your reasoning.
This code can be solved in 4 to 8 lines.

For this problem use the following variables:

For the mean use: Mean_of_data

For Standard Deviation use: Standard_deviation_of_data

Solutions

Expert Solution

mean_used <- 10 # mean provided
std_used <- 40 # standard deviation provided
sample_size <- c(2:600) # Size of each sample
mean_of_data <- rep(0, 599) # variable to hold the mean from the sample

simulated_data <- data.frame(sample_size, mean_of_data) # Data frame to hold the sample size and mean of the data
list2 <- c() # Empty list to hold the sample size
set.seed(1001) # To get the same sample each time
# Now we will run a loop to generate 2 to 600 samples and store the mean in our data frame
for (i in sample_size) {
list2 <- c(list2, rnorm(i, mean_used, std_used))
simulated_data$mean_of_data[i-1] <- mean(rnorm(i, mean_used, std_used))
}
# Plot Mean on the Xaxis and Sample size on the Yaxis
plot(simulated_data$mean_of_data, simulated_data$sample_size, main = "Mean of Sample vs Size of Sample",
xlab = "Mean of Sample", ylab = "Size of Sample")
# Calculate the density of the 600 samples
density_of_data <- dnorm(list2, mean_used, std_used)
# Plotting the density
plot(density_of_data)


Related Solutions

A) If a normal distribution has a mean µ = 40 and a standard deviation σ...
A) If a normal distribution has a mean µ = 40 and a standard deviation σ = 2, what value of x would you expect to find 2 standard deviations below the mean B) If a normal distribution has a mean µ = 70 and a variance σ2 = 16, what value of x would you expect to find 2.5 standard deviations above the mean? C)If a sample yields a mean xmean = 44 and we know that the sum...
for certain rainfall data, the standard deviation Sx = 3.4 mm. If the Normal distribution was...
for certain rainfall data, the standard deviation Sx = 3.4 mm. If the Normal distribution was used and the 10 year rain x10 = 34.1 mm, then the 2 year rain x2 is: 6.82 mm 29.74 mm 31.72 mm 38.18 mm
A normal population has a mean of 18.6 and a standard deviation of 3.4. Refer to...
A normal population has a mean of 18.6 and a standard deviation of 3.4. Refer to the table in Appendix B.1. a. Compute the z-value associated with 25.0. (Round the final answer to 2 decimal places.) z = b. What proportion of the population is between 18.6 and 25.0? (Round z-score computation to 2 decimal places and the final answer to 4 decimal places.) Proportion c. What proportion of the population is less than 18.0? (Round z-score computation to 2...
A population has a normal distribution with a mean of 51.4 and a standard deviation of...
A population has a normal distribution with a mean of 51.4 and a standard deviation of 8.4. Assuming n/N is less than or equal to 0.05, the probability, rounded to four decimal places, that the sample mean of a sample size of 18 elements selected from this population will be more than 51.15 is?
A population has a normal distribution with a mean of 51.5 and a standard deviation of...
A population has a normal distribution with a mean of 51.5 and a standard deviation of 9.6. Assuming , the probability, rounded to four decimal places, that the sample mean of a sample of size 23 elements selected from this populations will be more than 51.15 is:
If an IQ distribution is normal and has a mean of 100 and a standard deviation...
If an IQ distribution is normal and has a mean of 100 and a standard deviation of 15, then 99% of all those taking the test scored between IQ's of A. 0 and 150 B. 55 and 145 C. 92.5 and 107.5
Suppose Z has a standard normal distribution with a mean of 0 and standard deviation of...
Suppose Z has a standard normal distribution with a mean of 0 and standard deviation of 1. The probability that Z is less than 1.15 is
Consider a normal distribution with a mean of 50 and standard deviation of 10. Which of...
Consider a normal distribution with a mean of 50 and standard deviation of 10. Which of the following is FALSE? Question 4 options: P(x<=50) = .50 P(x>=40) = 1-P(x<40) P(x<=20)+P(x<=20) = P(x<=40) P(x<=30) = P(x>=70)
Which normal distribution has a wider​ spread: the one with mean 4 and standard deviation 9...
Which normal distribution has a wider​ spread: the one with mean 4 and standard deviation 9 or the one with mean 9 and standard deviation 4​?
Given a distribution that has a mean of 40 and a standard deviation of 13, calculate...
Given a distribution that has a mean of 40 and a standard deviation of 13, calculate the probability that a sample of 49 has a sample mean that is no more than 35  
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT