make_MC_sample: Makes a Monte Carlo sample using Sobol' sequences

Description Usage Arguments Value See Also Examples

Description

Generates a Monte Carlo sample using Sobol' low-discrepancy quasi-random sequences. Random sampling with R's standard methods is inefficient for Monte Carlo analysis as the sampled values do not cover the parameter space evenly. This function allows users to create parameter samples using quasi-random low-discrepancy Sobol' sequences to get around this problem.

Usage

1
make_MC_sample(n, vals)

Arguments

n

number of samples to draw

vals

a list describing distributions. Each list entry should consist of the following named fields:

  • var a variable name

  • dist the distribution name, e.g. 'unif' for Uniform (see R's distribution names)

  • params a list of distribution parameters. The list names will vary by distribution.

Value

a data frame with an index column "n" and each distribution in a named column

See Also

https://gist.github.com/jkeirstead/1730440

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
{
## Define the distributions
vals <- list(list(var="Uniform",
              dist="unif",
              params=list(min=0,max=1)),
         list(var="Normal",
              dist="norm",
              params=list(mean=0,sd=1)),
         list(var="Weibull",
              dist="weibull",
              params=list(shape=2,scale=1)))

## Generate 100 samples
samp <- make_MC_sample(100, vals)
}

jkeirstead/jkr documentation built on May 19, 2019, 11:41 a.m.