Question

In: Statistics and Probability

Applying the Central Limit Theorem in R Please click on the link above to participate in...

Applying the Central Limit Theorem in R

Please click on the link above to participate in this week's discussion.

We can design an experiment to see how the Central Limit Theorem applies practically. Execute the following commands in R:

  1. Initialize the variables we will use:

> mu <- 100
> sigma <- 10
> n <- 5
> numSims <- 500
> xbar <- rep(0,numSims)

mu is the mean, sigma is the standard deviation of the normal distribution we will use. n is the size of the samples that we will use and xbar will be a vector of size numSims, in which we will put sample means.

  1. Generate a sample of size n and compute the mean of the sample. This will be repeated numSims times.

> for (i in 1:numSims)
{xbar[i]=mean(rnorm(n,mean=mu,sd=sigma))}

  1. Plot a histogram of the distribution of the sample means:

> hist(xbar,prob=TRUE,breaks=12,xlim=c(70,130),ylim=c(0,0.1))

What is the shape of the histogram that you drew and what distribution does it represent?

How would expect the graph to change if you changed the values for:

  1. mu
  2. sigma
  3. n
  4. numSims

What do you expect the change to be if you changed the distribution that’s being used? What if instead of rnorm, we used rpois with lambda = mu? Would you expect the graph to change much, given what you know about the Central Limit Theorem?

Solutions

Expert Solution

The R code for generating 500 samples of sample size and plotting the histogram is given below.

mu <- 100
sigma <- 10
n <- 5
numSims <- 500
xbar <- rep(0,numSims)
for (i in 1:numSims)
{
xbar[i]=mean(rnorm(n,mean=mu,sd=sigma))
}
plot(1:1)
dev.new()
hist(xbar,prob=TRUE,breaks=12,col="sky blue", main="Histogram of Means", xlim=c(70,130),ylim=c(0,0.1))

The shape of the histogram is bell shaped. The distribution of means is approximately normal with .

If you change , the histogram shift to right when increases and vice versa.

If you reduce , the histogram becomes more centered. Otherwise spread of the histogram increases.

If you increase the histogram approaches true normal distribution.

Increasing numSims does not have much effect on the histogram.

If you change the distribution to Poisson, the R code below.

mu <- 100
sigma <- 10
n <- 5
numSims <- 5000
xbar <- rep(0,numSims)
for (i in 1:numSims)
{
xbar[i]=mean(rpois(n,lambda=mu))
}
plot(1:1)
dev.new()
hist(xbar,prob=TRUE,breaks=12,col="sky blue", main="Histogram of Means", xlim=c(70,130),ylim=c(0,0.1))

The histogram is

There is not much change in the graph which is the result of CLT. According to CLT, for all distributions the distribution of means is approximately normal.


Related Solutions

Applying the Central Limit Theorem: The amount of contaminants that are allowed in food products is...
Applying the Central Limit Theorem: The amount of contaminants that are allowed in food products is determined by the FDA (Food and Drug Administration). Common contaminants in cow milk include feces, blood, hormones, and antibiotics. Suppose you work for the FDA and are told that the current amount of somatic cells (common name "pus") in 1 cc of cow milk is currently 750,000 (note: this is the actual allowed amount in the US!). You are also told the standard deviation...
Applying the Central Limit Theorem: The amount of contaminants that are allowed in food products is...
Applying the Central Limit Theorem: The amount of contaminants that are allowed in food products is determined by the FDA (Food and Drug Administration). Common contaminants in cow milk include feces, blood, hormones, and antibiotics. Suppose you work for the FDA and are told that the current amount of somatic cells (common name "pus") in 1 cc of cow milk is currently 750,000 (note: this is the actual allowed amount in the US!). You are also told the standard deviation...
Applying the Central Limit Theorem: The amount of contaminants that are allowed in food products is...
Applying the Central Limit Theorem: The amount of contaminants that are allowed in food products is determined by the FDA (Food and Drug Administration). Common contaminants in cow milk include feces, blood, hormones, and antibiotics. Suppose you work for the FDA and are told that the current amount of somatic cells (common name "pus") in 1 cc of cow milk is currently 750,000 (note: this is the actual allowed amount in the US!). You are also told the standard deviation...
This is the code in R for the Central Limit theorem question. This is Exponential distribution...
This is the code in R for the Central Limit theorem question. This is Exponential distribution with mean beta. How can I modify this code to Bernoulli(0.1), Uniform (0,4), and Normal distribution (2,1)    plot.z <- function(n, m=1e5, beta = 1) { mu <- beta sigma <- beta zs <- rep(0,m) for(i in 1:m) { Y.sample <- rexp(n, 1/beta) Ybar <- mean(Y.sample) zs[i] <- (Ybar - mu) / (sigma / sqrt(n)) } p <- hist(zs, xlim=c(-4,4), freq = F, main =...
This week we’ve introduced the central limit theorem. According to the central limit theorem, for all...
This week we’ve introduced the central limit theorem. According to the central limit theorem, for all samples of the same size n with n>30, the sampling distribution of x can be approximated by a normal distribution. In your initial post use your own words to explain what this theorem means. Then provide a quick example to explain how this theorem might apply in real life. At last, please share with us your thoughts about why this theorem is important.
Applying the Central Limit Theorem, suppose that personal computers (PC) have a mean of weight of...
Applying the Central Limit Theorem, suppose that personal computers (PC) have a mean of weight of 7.5 pounds with a standard deviation of 1.1 pounds. If you take a sample of the weight of 50 different brands of PC, the sample standard deviation is: Select one: a. 7.5 1.1 7.51.1 b. 1.1 50 √ 1.150 c. 7.5+1.1 7.5+1.1
Demonstrate understanding of the Central Limit Theorem, using R, by showing how the distribution of the...
Demonstrate understanding of the Central Limit Theorem, using R, by showing how the distribution of the sample mean changes according to sample size. Consider a Poisson distribution with λ = 1.5. Generate samples of 10,000 means over different numbers of observations (eg give a matrix 1, 2,3...100) rows. For each of these samples of means, compute the mean of the means, the sample standard deviation of the means, and the proportions of means that are more than 1 standard deviation...
This problem involves using R to examine the Central Limit Theorem more in detail. For all...
This problem involves using R to examine the Central Limit Theorem more in detail. For all answers in this problem, round to four decimal places. We will first generate 10 Poisson(λ=1) random variables and then calculate the sample mean of these 10 random variables. We will do this process 10,000 times to generate 10,000 simulated sample means. Run the following code and use the output to answer the following questions. set.seed(2020) nsims = 10000 # number of simulations means =...
It is said that the Central Limit Theorem is the most important theorem in all of...
It is said that the Central Limit Theorem is the most important theorem in all of Statistics. In your own words, describe why it is so important.
Watch the attached video then click on the above link "The Fed " and create a...
Watch the attached video then click on the above link "The Fed " and create a thread with at least one page answering and explaining the following: What is the mission, or goals, of the Fed? Explain the structure of the Fed and the hierarchy of governance. Is the Fed a public or private entity? Who owns the Fed? If issuing Federal Reserve Notes stimulates the economy, why not print money indefinitely? Under what conditions would the Fed purchase securities...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT