StableMonteCarloSamples: StableMonteCarloSamples

View source: R/StableMonteCarloSamples.R

StableMonteCarloSamplesR Documentation

StableMonteCarloSamples

Description

StableMonteCarloSamples returns a list of samples from executing the function with arguments. This differs to the GenMonteCarloSamples by traking the samples and stopping when a confidence interval from an estimate is reached.

Usage

StableMonteCarloSamples(
  calc,
  calc_args,
  estimate,
  tolerance = 10^(-min(round(log10(abs(estimate))), 2.1)),
  confidence = 0.9,
  start = 10,
  limit = 1e+08,
  rolling_window = 3,
  debug = FALSE,
  trace = 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

In hindsite after writing this by experimentation with a logistics curve concept I realised that this could be done with a PID method.

Value

samples The return values from the calc function

Examples


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

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