25th June, 2020

Objective

This is a web page presentation created using R Markdown. This presentation is created to demonstrate my understanding of the topic. Being a very important concept which is also often not well understood, I will be demonstrating the concept visually using the shiny package.

Definition:

Central Limit Theorem. The central limit theorem states that if you have a population with mean μ and standard deviation σ and take sufficiently large random samples from the population with replacement , then the distribution of the sample means will be approximately normally distributed.

Process

User can select the range of numbers, sample size and the number of samples. When we increase the number of sample to 1000s, the histogram starts looking like a normal graph which indicates that as the number of sample tends to infinity, the mean of population is the mean of the range of numbers.

When the user clicks on the submit button, the application
1. Creates samples of sepcified size. It should be noted that the numbers are replaced during sampling and every number has equal chance of getting selected.
2. Finds out the average of each sample.
3. Creates the histogram of the averages.

Code

mean_pop <- reactive({
        range_min <- input$range[1]
        range_max <- input$range[2]
        averages <- range_min:range_max
        set.seed(666)
        for (i in 1:input$num_sample) {
            averages[i] <- mean(sample(range_min:range_max, 
                                       input$sample_size, 
                                       replace = TRUE))
        }
        averages <- data.frame(averages)
        return(averages)
    })

Shiny Application

You may access the shiny application here:
Shiny Application

The code can be found in the folder named ‘CLT’