View source: R/ASCBRMonteCarloSamples.R
ASCBRMonteCarloSamples | R Documentation |
ASCBRMonteCarloSamples
returns a list of samples from executing the function
with arguments. This differs to the GenMonteCarloSamples by tracking the
samples and stopping when a confidence interval from an estimate is reached.
Ata, Mustafa Y.. (2007). A convergence criterion for the Monte Carlo
estimates. Simulation Modeling Practice and Theory. 15. 237-246.
10.1016/j.simpat.2006.12.002.
ASCBRMonteCarloSamples(
calc,
calc_args,
estimate_upper,
estimate_lower,
err,
zeta,
limit = 1e+08,
debug = FALSE
)
calc |
A function to sample |
calc_args |
A function to create arguments for the func being sampled |
iterations |
The number of samples to create |
This algorithm has a bug with stable non variant functions. The 100 minimum run would push the value of z outside the value of zeta and so would never end the internal loop. This condition was change from z!=zeta to z>zeta to solve this problem.
Using this function requires some pre existing understanding of the range (CI) to allow the values for zeta, upper and lower values. If set incorrectly these will mean the algorithm will not end. The limit was added to stop these issues
This algorithm evaluates the end condition for every run of the calculation. This does not optimise well for unstable functions. It does not do testing of the end condition after batches or do estimates of the next batch size before testing again.S
This algorithm has type range issues for the end condition. If the sum of the results is larger than the type can hold it will overflow.
samples The return values from the calc function
calc_estimate <- function(v, ef) {
return(v + 1)
}
calc_args <- function() {
return(list(10))
}
ASCBRMonteCarloSamples(calc_estimate, calc_args, 11) # returns samples
# @export
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.