Description Usage Arguments Value References Examples
Provides a flexible demonstration of the central limit theorem. Particularly, this function uses the theoretical parameters from one of three specific distributions to show the distribution of the sample mean approaches a normal distribution. The user can choose between three distributions:
binormal A binormal distribution X|Z ~ N(Z, s)
uniform A uniform distribution such that X ~ U[a, b]
gamma A gamma distribution, X ~ Γ(a, b)
The central limit theorem essentially guarantees that, for a large enough sample size of independent samples, the distribution of the mean from a probability-based sample converges to a standard normal distribution. This is the basis for using normal and t-distributed confidence intervals.
1 | clt_demo(n = 20, N = 10000, distribution = "binormal", a = 30, b = 50, s = 6)
|
n |
The sample size to draw from a specified distribution. This defaults to n=30, but can be experimented with to see what the distribution looks like when under larger and smaller sample sizes. This method requires n >= 2. |
N |
The total number of replications to make in the simulation. This number is saying how many data points to use when constructing the histogram, so it should be fairly large. This method must be N >= 100. |
distribution |
One of "binormal", "uniform", or "gamma". |
a |
In each distribution, this has a different function.
|
b |
As with a, b specifies a specific parameter in a distribution. Note in the binormal case, a = b will produce a unimodal normal distribution.
|
s |
The standard deviation for a normal distribution. Can be ignored or specified as NULL when using other distributions, although this isn't strictly necessary. |
A list with
data Samples drawn from the specified distribution
plot A histogram of the results
popmean The population mean for the specified distribution
popvariance The population variance for the specified distribution
Billingsley, Patrick. Probability and measure. John Wiley & Sons, 2008.
1 2 3 | # Can be run without passing any arguments
clt <- clt_demo()
# Use clt$plot to obtain the graph
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.