Skip to content

Instantly share code, notes, and snippets.

@sc268
Last active February 8, 2020 11:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sc268/3c17919bcbd8553d10cea0627a140dbd to your computer and use it in GitHub Desktop.
Save sc268/3c17919bcbd8553d10cea0627a140dbd to your computer and use it in GitHub Desktop.
nruns = 10000
FPR <- function(population, allowedFailedRatio){
allowFails = population * allowedFailedRatio
count = match = 0
while (count < nruns) {
x <- rnorm(population, 0, 1)
if (sum(x > 2 | x < -2) <= allowFails){
match = match + 1
}
count = count + 1
}
1 - match / count
}
FPR(20, 0.10) #0.0618
FPR(20, 0.05) #0.2313
FPR(1000, 0.10) #0
FPR(1000, 0.05) #0.2218
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment