# 15.2: Simulating the Maximum Finishing Time


Let’s simulate 150 samples, collecting the maximum value from each sample, and then plotting the distribution of maxima.

# sample maximum value 5000 times and compute 99th percentile
nRuns <- 5000
sampSize <- 150

sampleMax <- function(sampSize = 150) {
samp <- rnorm(sampSize, mean = 5, sd = 1)
return(tibble(max=max(samp)))
}

input_df <- tibble(id=seq(nRuns)) %>%
group_by(id)

maxTime <- input_df %>% do(sampleMax())

cutoff <- quantile(maxTime\$max, 0.99)

ggplot(maxTime,aes(max)) +
geom_histogram(bins = 100) +
geom_vline(xintercept = cutoff, color = "red")

This page titled 15.2: Simulating the Maximum Finishing Time is shared under a not declared license and was authored, remixed, and/or curated by Russell A. Poldrack via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.