# How to display central limit theorem using uniform random variable in R?

R ProgrammingServer Side ProgrammingProgramming

#### Artificial Intelligence : The Future Of Programming

15 Lectures 54 mins

#### Beyond Basic Programming - Intermediate Python

Most Popular

36 Lectures 3 hours

#### C Programming from scratch- Master C Programming

Best Seller

60 Lectures 8 hours

The central limit theorem says that as the sample size increases the distribution of the sample means approaches normal distribution. Therefore, irrespective of the actual population distribution if we take samples of larger size and find the mean of these samples then the distribution of these sample means will be approximately normal. We can display this in R, by creating the histogram of such type of means.

## Example1

> x<-replicate(5000,{x1<-runif(5,1,2)
+ mean(x1)})
> hist(x)

## Example2

> y<-replicate(10000,{y1<-runif(5,1,2)
+ mean(y1)})
> hist(y)

## Output

Updated on 23-Nov-2020 10:48:55