Skip to contents

get_sample_errors(prob, setup, test_dt, numruns = n, solution_runs = m) estimates the sampling error of the mean final value over n runs of an SDE algorithm: 1.96 times the standard deviation, over m repetitions, of the distance between the mean final value and the analytic mean (the mean of analytic(u0, p, T, W) over sample_error_runs normal W with variance T - t0, or without an analytic solution the mean over all runs), divided by sqrt(n). With a vector numruns it returns one value per entry. Runs without an analytic solution are compared with a reference solved by appxsol_setup on a Brownian grid of step test_dt.

Usage

get_sample_errors(
  prob,
  setup,
  test_dt = NULL,
  appxsol_setup = NULL,
  numruns,
  error_estimate = "final",
  sample_error_runs = 1e+07,
  solution_runs,
  parallel_type = "none",
  ...,
  p = NULL
)

Arguments

prob

An SDE or RODE problem.

setup

A setup.

test_dt

Step of the Brownian grid of reference solutions.

appxsol_setup

Setup of the reference.

numruns

Number of runs, or a vector of them.

error_estimate

Unused, as in Julia.

sample_error_runs

Number of samples of the analytic mean.

solution_runs

Number of repetitions.

parallel_type

"none" or "threads" (forked workers).

...

Solver options.

p

The solver option p, named in the signature so that it does not partially match prob and parallel_type.

Value

A number or a vector.

Examples

f <- function(u, p, t) 0.5 * u
g <- function(u, p, t) 0.2 * u
an <- function(u0, p, t, W) u0 * exp(0.48 * t + 0.2 * W)
prob <- SDEProblem(SDEFunction(f, g, analytic = an), 1, c(0, 1))
set.seed(1)
get_sample_errors(prob, list(alg = EM(), dts = 1 / 4), numruns = 3, solution_runs = 2,
  sample_error_runs = 100)
#> Solution Run: 1
#> Solution Run: 2
#> [1] 0.0571924