ASCBRMonteCarloSamples: ASCBRMonteCarloSamples

View source: R/ASCBRMonteCarloSamples.R

ASCBRMonteCarloSamplesR Documentation

ASCBRMonteCarloSamples

Description

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.

Usage

ASCBRMonteCarloSamples(
  calc,
  calc_args,
  estimate_upper,
  estimate_lower,
  err,
  zeta,
  limit = 1e+08,
  debug = FALSE
)

Arguments

calc

A function to sample

calc_args

A function to create arguments for the func being sampled

iterations

The number of samples to create

Details

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.

Value

samples The return values from the calc function

Examples


calc_estimate <- function(v, ef) {
  return(v + 1)
}
calc_args <- function() {
  return(list(10))
}
ASCBRMonteCarloSamples(calc_estimate, calc_args, 11) # returns samples


# @export

micko920/MonteCarloUtils documentation built on Oct. 27, 2023, 8:23 p.m.