Skip to content

Instantly share code, notes, and snippets.

@CerebralMastication
Created February 24, 2010 22:54
Show Gist options
  • Save CerebralMastication/313987 to your computer and use it in GitHub Desktop.
Save CerebralMastication/313987 to your computer and use it in GitHub Desktop.
makeDraws <- function(numberOfDraws) {
i <- 1
myOutput <- rep(NA, numberOfDraws) #preallocate the vector so it all goes faster
while (i <= numberOfDraws) {
a <- runif(7, 0, 100) #random draws from a uniform dist 0,100
b <- runif(7, 0, 100)
absDiff <- abs(a-b) #calculate the absolute diff
myOutput[i] <- sum(absDiff) #sum up the diffs and put them in the output vector
i <- i +1
}
myOutput #return the output vector
}
myDraws <- makeDraws(1e6) #start with 1mm draws
min(myDraws)
quantile(myDraws, .0001)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment