Skip to contents

McIntegrate: integral and mean of f over a box or polygon (plain, antithetic or Latin hypercube sampling). McStratified: stratified estimate with proportional or Neyman allocation. McZonal: hit-or-miss zone area and zone mean. McControlVariate: control-variate estimator. McConvergence: running mean band and batch-means standard error. Identical to the Python arm morie.fn.mcspatial.

Usage

McIntegrate(
  f,
  bounds = NULL,
  polygon = NULL,
  n = 10000,
  seed = 1,
  method = "plain"
)

McStratified(
  f,
  strata,
  n = 1000,
  allocation = "proportional",
  pilot_sd = NULL,
  seed = 1
)

McZonal(indicator, bounds, value = NULL, n = 10000, seed = 1)

McControlVariate(y, g, g_mean)

McConvergence(samples, batches = 20)

Arguments

f

Function of the coordinates.

bounds

Matrix of (lower, upper) rows per dimension.

polygon

Two-column polygon vertices.

n

Number of points.

seed

Philox seed.

method

"plain", "antithetic" or "lhs".

strata

List of polygons.

allocation

"proportional" or "neyman".

pilot_sd

Pilot standard deviations per stratum.

indicator

Zone membership function.

value

Function averaged over the zone.

y, g

Samples and control variate.

g_mean

Known mean of the control.

samples

Monte Carlo sample.

batches

Number of batches.

Value

List.

References

Cochran, W. G. (1977). Sampling Techniques, 3rd ed. Wiley.

McKay, M. D., Beckman, R. J. and Conover, W. J. (1979). A comparison of three methods for selecting values of input variables in the analysis of output from a computer code. Technometrics 21, 239-245.

Flegal, J. M., Haran, M. and Jones, G. L. (2008). Markov chain Monte Carlo: can we trust the third significant figure? Statistical Science 23, 250-260.

Examples

McIntegrate(function(x, y) x + y, bounds = rbind(c(0, 1), c(0, 1)), n = 2000,
  method = "lhs")$integral
#> [1] 0.999997
McConvergence(c(1, 3, 2, 4), batches = 2)$batch_se
#> [1] 0.5