Created
February 24, 2010 22:54
-
-
Save CerebralMastication/313987 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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