Description Usage Arguments Value Examples
Use Monte Carlo Simulation on anonymous test function
1 2 3 4 5 6 7 |
test |
An anonymous test function |
on |
A vector of values to sample from |
reps |
The number of samples for each iteration of test |
sims |
The number of test iterations |
replace |
Replace argument from the base R function: sample(x, size, replace = FALSE, prob = NULL) |
A vector with test results for "sims" iterations of the test
1 2 3 4 5 6 7 | #The default settings of simtest checks whether reps = 10 samples from
#"on = c(0, 1)" returns a value of "1" three or more times. This can be thought of
#as a test for whether flipping a coin 10 times returns heads three or more times.
#Example and function inspired from A Beginner's Guide to Monte Carlo Simulations
#presented by Dan Uehara for UseR Oslo: https://www.youtube.com/watch?v=g2Uu9m0IlFE
coinflips <- simtest()
mean(coinflips)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.