After placing the file βpop2.csv" in the working directory one may produce a data frame with the content of the file and compute the average of the variable βbmi" using the code:
In order to compute the expectation under the sampling distribution of the sample average we conduct a simulation. The simulation produces (an approximation) of the sampling distribution of the sample average. The sampling distribution is represented by the content of the sequence βX.bar":
Initially, we produce a vector of zeros of the given lenght (100,000). In each iteration of the βfor" loop a random sample of size 150 is selected from the population. The sample average is computed and stored in the sequence βX.bar". At the end of all the iterations all the zeros are replaced by evaluations of the sample average.
The expectation of the sampling distribution of the sample average is computed by the application of the function βmean" to the sequence that represents the sampling distribution of the sample average. The result for the current is 24.98681, which is vary similar[^3] to the population average 24.98446.
The resulting standard deviation is 0.3422717. Recall that the standard deviation of a single measurement is equal to 4.188511 and that the sample size is \(n=150\text{.}\) The ratio between the standard deviation of the measurement and the square root of 150 is \(4.188511/\sqrt{150} =0.3419905\text{,}\) which is similar in value to the standard deviation of the sample average[^4].
The value 24.54972 is the 10%-percentile of the sampling distribution. To the left of this value are 10% of the distribution. The value 25.42629 is the 90%-percentile of the sampling distribution. To the right of this value are 10% of the distribution. Between these two values are 80% of the sampling distribution.
The Normal approximation, which is the conclusion of the Central Limit Theorem substitutes the sampling distribution of the sample average by the Normal distribution with the same expectation and standard deviation. The percentiles are computed with the function βqnorm":
Observe that we used the expectation and the standard deviation of the sample average in the function. The resulting interval is \([24.54817, 25.42545]\text{,}\) which is similar to the interval \([24.54972, 25.42629]\) which was obtained via simulations.
Denote by \(X\) the distance from the specified endpoint of a random hit. Observe that \(X \sim \mbox{Uniform}(0,10)\text{.}\) The 25 hits form a sample \(X_1, X_2, \ldots, X_{25}\) from this distribution and the sample average \(\bar X\) is the average of these random locations. The expectation of the average is equal to the expectation of a single measurement. Since \(\Expec(X) = (a + b)/2 = (0 + 10)/2 = 5\) we get that \(\Expec(\bar X) = 5\text{.}\)
The variance of the sample average is equal to the variance of a single measurement, divided by the sample size. The variance of the Uniform distribution is \(\Var(X) = (a + b)^2/12 = (10-0)^2/12 = 8.333333\text{.}\) The standard deviation of the sample average is equal to the standard deviation of the sample average is equal to the standard deviation of a single measurement, divided by the square root of the sample size. The sample size is \(n=25\text{.}\) Consequently, the standard deviation of the average is \(\sqrt{8.333333/25}=0.5773503\text{.}\)
The left-most third of the detector is the interval to the left of 10/3. The distribution of the sample average, according to the Central Limit Theorem, is Normal. The probability of being less than 10/3 for the Normal distribution may be computed with the function βpnorm":
mu <- 5
sig <- sqrt(10^2/(12*25))
pnorm(10/3,mu,sig)
## [1] 0.001946209
The expectation and the standard deviation of the sample average are used in computation of the probability. The probability is 0.001946209, about 0.2%.
The central region in the \(\mbox{Normal}(\mu,\sigma^2)\) distribution that contains 99% of the distribution is of the form \(\mu \pm \mbox{\texttt{qnorm(0.995)}}\cdot \sigma\text{,}\) where βqnorm(0.995)" is the 99.5%-percentile of the Standard Normal distribution. Therefore, \(c =\mbox{\texttt{qnorm(0.995)}}\cdot \sigma\text{:}\)