Visualising Rnorm

E.Go
2020-06-16

About Random Normal Distributions

  • Commonly found in nature
  • Central Limit Theorem: all sampling distributions of unbiased estimators converge to a normal distribution
  • Centred around a mean value
  • Spread is determined by the standard deviation

Why this Shiny App?

  • Visualising the basic properties of normal distributions
    • How the distribution depends on the mean
    • How the distribution depends on the standard deviation
  • The general shape of the distribution doesn't change
    • but the axes shift

Backend - The Code

The UI

sliderInput("n", "Number of Points",
                min=100, max=1000, step=50, value=500),
sliderInput("mu", "Mean", -10, 10, value=0),
sliderInput("sd", "Standard Deviation", 0, 10, value=1)

The Server (Simplified Code)

x <- function(){
        x <- rnorm(input$n, input$mu, input$sd)
    }
data <- x()
mean(data)
sd(data)
hist(data)

Example: Standard Normal Distribution with n=500

[1] 0.03239527
[1] 1.014089

plot of chunk unnamed-chunk-1