stkp_CLT_cont <- function(pop,n_stkp,sim_aantal) {
if(pop %in% 1:2) {
  if(n_stkp >= 2 | n_stkp ==0) {   
    if(sim_aantal >= 1) {
      library(ggplot2)
      library(dplyr, warn.conflicts = FALSE)
      if(n_stkp == 0){ p <- ggplot(data.frame(x = 0), aes(x)) + 
        coord_cartesian(expand = FALSE, xlim = c(0, 1.05), ylim = c(0, 1.05)) +
        labs(title = "populatie X", subtitle = "f(x) = 1  voor 0 ≤ x ≤ 1 ", x = "x-waarde", y ="dichtheidsfunctie") +
        scale_x_continuous(breaks = seq(0, 1, by=0.1)) +
        scale_y_continuous(breaks = seq(0, 1, by=0.25)) +
        theme(plot.title = element_text(size = 15, hjust=0.5, vjust = 2.5),
              plot.subtitle = element_text(size = 15,hjust=0.5, ),
              axis.title.x = element_text(hjust = 0.5),
              axis.title.y = element_text(vjust = 0.5) ,
              aspect.ratio = 1 )
      if(pop == 1) {p <- p + geom_segment(aes(x = 0, y = 1, xend = 1, yend = 1))
      }else{
        p <- p + coord_cartesian(expand = FALSE, xlim = c(0, 1.05), ylim = c(0, 2.05)) +
          scale_y_continuous(breaks = seq(0, 2, by=0.25)) +
          labs(subtitle = "f(x) = 2x  voor 0 ≤ x ≤ 1 ") +
          geom_segment(aes(x = 0, y = 0, xend = 1, yend = 2)) }
      }else{
        n_stkp <- round(n_stkp)
        if(pop == 1) { x <- apply(replicate(sim_aantal, runif(n_stkp, 0,1)), 2, mean)
        }else{x <- apply(replicate(sim_aantal, sqrt(runif(n_stkp, 0,1))), 2, mean)}
        sim_aantal <- format(sim_aantal , scientific = F)
        lblsubt <- paste("steekproefgrootte n =", as.character(n_stkp), " |  aantal herhalingen sim =", sim_aantal)
        lbltitle <- bquote("simulatie steekproefgemiddelde" ~ bar(X))
        lblx <-  bquote(bar(x) ~ "- waarde ") 
        lbly <- "dichtheidsschaal"
        if((max(x) - min(x)) == 0){
          xmin <- min(x) - 0.5
          xmax <- max(x) + 0.5
        }else{
          xmin <- min(x) - (max(x)-min(x))*0.05
          xmax <- max(x) + (max(x)-min(x))*0.05 }   
        binw <- (xmax - xmin)/45
        p <- ggplot(data.frame(x), aes(x)) + 
          coord_cartesian (xlim= c(xmin,xmax)) +
          scale_y_continuous(expand = expansion(mult = c(0, .05))) +
          scale_x_continuous(expand = expansion(add = c(0, 0))) +
          labs(title = lbltitle, subtitle = lblsubt,  x = lblx, y =lbly) +
          theme(plot.title = element_text(size = 15, hjust=0.5),
                plot.subtitle = element_text(hjust=0.5),
                axis.title.x = element_text(hjust = 0.5),
                axis.title.y = element_text(vjust = 0.5) ,
                aspect.ratio = 1 ) +
          geom_histogram(aes(y=after_stat(density)), binwidth=binw, color = "grey30", fill = "white") }
      p
    } else {
      cat("het aantal herhalingen in de simulatie \nmoet minstens gelijk aan 1 zijn \npas aan: sim_aantal <- ...")  }
  } else {
    cat("de steekproefgrootte moet \nminstens gelijk aan 2 zijn \npas aan: n_stkp <-... ")  }
} else {
  cat("voor pop vul je ofwel 1 ofwel 2 in \npas aan: pop <- ...")  }          
}