Question

In: Math

Using the language R Generate five random data sets that follow the normal random distribution with...

Using the language R

Generate five random data sets that follow the normal random distribution with mean 5, variance 2. The sizes of these five data sets is 10, 100, 1000, 10000 and 100000. Draw the histogram, boxplot and QQ-plot (normal probability plot) of five data sets. Please make comments about these plots

Solutions

Expert Solution

R-code


# Random data generation for normal distribution with mean 5 and variance 2

v_mu = 5       # mean of the normal distribution
v_sd = sqrt(2)      # standard deviation of the normal distribution (sqroot of variance)
v_mu
v_sd

par(mfrow=c(2,3))
set.seed(19561)

# dataset of size 10
n = 10
v_title = "QQ plot for size 10"
v_tithist = "Histogram for size 10"
v_titbox = "Boxplot for size 10"
d1 <- rnorm(n, v_mu, v_sd)
qqnorm(d1, main = v_title)
hist(d1, main = v_tithist)
boxplot(d1, main = v_titbox)

# dataset of size 100
n = 100
v_title = "QQ plot for size 100"
v_tithist = "Histogram for size 100"
v_titbox = "Boxplot for size 100"
d2 <- rnorm(n, v_mu, v_sd)
qqnorm(d2, main = v_title)
hist(d2, main = v_tithist)
boxplot(d2, main = v_titbox)

# dataset of size 1000
n = 1000
v_title = "QQ plot for size 1000"
v_tithist = "Histogram for size 1000"
v_titbox = "Boxplot for size 1000"
d3 <- rnorm(n, v_mu, v_sd)
qqnorm(d3, main = v_title)
hist(d3, main = v_tithist)
boxplot(d3, main = v_titbox)

# dataset of size 10000
n = 10000
v_title = "QQ plot for size 10000"
v_tithist = "Histogram for size 10000"
v_titbox = "Boxplot for size 10000"
d4 <- rnorm(n, v_mu, v_sd)
qqnorm(d4, main = v_title)
hist(d4, main = v_tithist)
boxplot(d4, main = v_titbox)


# dataset of size 100000
n = 100000
v_title = "QQ plot for size 100000"
v_tithist = "Histogram for size 100000"
v_titbox = "Boxplot for size 100000"
d5 <- rnorm(n, v_mu, v_sd)
qqnorm(d5, main = v_title)
hist(d5, main = v_tithist)
boxplot(d5, main = v_titbox)

R-output

Comment

From the above plots we can see that

As the sample size increases, the qqplots are close to a straight line

As the sample size increases, the histograms appear to be more symmetric and bell shaped

As the sample size increases, the box plots become symmetric and the mean and median divide the box symmetrically.

This proves the Central Limit Theorem that "As sample sizes increase, the sampling distributions approach a normal distribution"


Related Solutions

Coding Language: R Generate 100 observations from the normal distribution with mean 3 and variance 1....
Coding Language: R Generate 100 observations from the normal distribution with mean 3 and variance 1. Compute the sample average, the standard error for the sample average, and the 95% confidence interval. Repeat the above two steps 1000 times. Report (a) the mean of the 1000 sample means, (b) the standard deviation of the 1000 sample means, (c) the mean of the 1000 standard errors, and (d) how many times (out of 1000) the 95% confidence intervals include the population...
Write the R code to generate five independent uniform random numbers and use that to generate...
Write the R code to generate five independent uniform random numbers and use that to generate 5 independent Bernoulli random variables with probability of success p = 0.4. please use RStudio. please do not use lab nor rbern for calculations.
(a) Generate n=10 random sample from a population with normal(40,1) distribution. (b) For data in part...
(a) Generate n=10 random sample from a population with normal(40,1) distribution. (b) For data in part (a) find a 95% confidence interval for mu (the mean of the population). Can I claim that the mean is 41? If your answer is "yes" to this question, which one is the mean? 40 or 41? (c) For data in part (a) find a 99% confidence interval for sigma (the standard deviation of the population).
Generate 1000 random numbers from ??3? starting with standard normal random numbers in R.
Generate 1000 random numbers from ??3? starting with standard normal random numbers in R.
Go into R and view all of the data sets preloaded in R by using the...
Go into R and view all of the data sets preloaded in R by using the data() command. As you see there are quite a few data sets loaded into R. Now retrieve the dataset women using data(women). This data is from a random sample of 15 women, recording the height and weight of each woman in the sample. I want you to create a 95% confidence interval for the population mean using this data and R. First find the...
Generate 1000 random numbers from a normal distribution with mean 1 and variance 2 using Box‐Muller...
Generate 1000 random numbers from a normal distribution with mean 1 and variance 2 using Box‐Muller transformation in R.
Let the random variable X follow a normal distribution with a mean of μ and a...
Let the random variable X follow a normal distribution with a mean of μ and a standard deviation of σ. Let 1 be the mean of a sample of 36 observations randomly chosen from this population, and 2 be the mean of a sample of 25 observations randomly chosen from the same population. a) How are 1 and 2 distributed? Write down the form of the density function and the corresponding parameters. b) Evaluate the statement: ?(?−0.2?< ?̅1 < ?+0.2?)<?(?−0.2?<...
A computer was used to generate ten random numbers from a normal distribution with a set...
A computer was used to generate ten random numbers from a normal distribution with a set of unknown mean and variance: −1.1623, 0.2210, 1.6518, −1.1312, −0.2879, −1.0458, 1.3706, −0.7492, −0.1355, −1.2686. Eight more random normal numbers with the same variance perhaps a different mean were then generated (the mean may or may not actually be different): 0.3472, 2.2437, 1.0712, 2.5906, 0.5163, −1.1743, 0.0473, −0.8338. (a) What do you think the means of the random normal number generators were? What do...
Generate 1000 random numbers from ??2, 5? starting with standard normal random numbers in R.
Generate 1000 random numbers from ??2, 5? starting with standard normal random numbers in R.
let the random variable x follow a normal distribution with μ = 50 and σ2 =...
let the random variable x follow a normal distribution with μ = 50 and σ2 = 64. a. find the probability that x is greater than 60. b. find the probability that x is greater than 35 and less than 62 . c. find the probability that x is less than 55. d. the probability is 0.2 that x is greater than what number? e. the probability is 0.05 that x is in the symmetric interval about the mean between...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT