clt_demo: Central Limit Theorem Demo

Description Usage Arguments Value References Examples

View source: R/clt_demo.R

Description

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:

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.

Usage

1
clt_demo(n = 20, N = 10000, distribution = "binormal", a = 30, b = 50, s = 6)

Arguments

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.

  • binormal The mean of one of the normal distributions

  • uniform The left endpoint of a uniform distribution

  • gamma The shape parameter in a gamma distribution

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.

  • binormal The mean of one of the normal distributions

  • uniform The right endpoint of a uniform distribution

  • gamma The rate parameter of a uniform 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.

Value

A list with

References

Billingsley, Patrick. Probability and measure. John Wiley & Sons, 2008.

Examples

1
2
3
# Can be run without passing any arguments
clt <- clt_demo()
# Use clt$plot to obtain the graph

danjdrennan/surveyr documentation built on Dec. 19, 2021, 8:08 p.m.