clt {learnPopGen} | R Documentation |
Illustrates the concept of the Central Limit Theorem
Description
The Central Limit Theorem tells us that when independent random variables are added together, the distribution of their sum tends towards a normal distribution, regardless of the shape of their individual distributions. This function attempts to illustrate this concept by allowing the user to visualize the sum of an arbitrary number of different independent random variables with different underlying distributions.
Usage
clt(nvar=1, nobs=1000, df=c("normal","uniform","exponential","binomial"),
theta=NULL, breaks="Sturges", show=c("sum","mean"))
## S3 method for class 'clt'
print(x, ...)
## S3 method for class 'clt'
plot(x, ...)
Arguments
nvar |
number of random variables to sum (1 or more). |
nobs |
total number of observations (per random variable). |
df |
distribution functions of individual random variables to sum. These can be |
theta |
parameter of the distribution functions: variance in the case of |
breaks |
breaks (see |
show |
whether to show the row-wise sum of the independent random variables ( |
x |
object of class |
... |
optional arguments for |
Details
The central limit theorem (CLT) establishes that when independent random variables are added together their (normalized) sum will tend towards a normal distribution, regardless of the distribution of the original random variables. That is to say if we were to generate a set of nvar
(say) independent, uniform, random variables, normalize each one to have the same variance, and then sum or average the variables by observation, this sum or average will tend towards a normal distribution as the number of random variables (nvar
in this function) is increased.
Value
Creates a plot showing the observation-wise distribution of the sum or average of the independent random variables.
The distribution of the observation-wise sum or average and the underlying data are also returned invisibly to the user in the form of an object of class "clt"
. This object can in turn be printed or re-plotted using custom print
and plot
methods. (See examples.)
Author(s)
Liam Revell liam.revell@umb.edu
See Also
Examples
clt(nvar=1,df="exponential")
clt(nvar=10,df="exponential")
object<-clt(nvar=40,df="exponential")
print(object)
plot(object)