MC_CRUDE: Crude Monte Carlo Simulation

View source: R/MC_CRUDE.R

MC_CRUDER Documentation

Crude Monte Carlo Simulation

Description

Crude Monte Carlo simulation (MC_CRUDE) method for the estimation of failure probabilities in structural reliability analysis.

The failure probability is estimated as

\hat{p}_f = \frac{1}{N} \sum_{i=1}^{N} \mathbf{1}_{\{g(\mathbf{X}_i) < 0\}}.

Failure is defined as g(x) < 0. Samples with g(x) = 0 are counted as safe.

Although conceptually simple and unbiased, the method becomes computationally inefficient for very small failure probabilities, as a large number of samples is required to obtain stable estimates.

Usage

MC_CRUDE(
  lsf,
  lDistr,
  cov_user = 0.05,
  n_batch = 10000,
  n_max = 1e+07,
  use_threads = NULL,
  backend = NULL,
  dataRecord = TRUE,
  debug.level = 0,
  seed = NULL
)

Arguments

lsf

Limit-state function. Must follow the LSF interface specification described in the "Limit-State Function (LSF) Interface" section below.

lDistr

List of distribution objects as returned by PROB_BASEVAR$getlDistr().

cov_user

Target coefficient of variation to be achieved.

n_batch

Number of samples per batch.

n_max

Maximum number of Monte Carlo samples.

use_threads

Number of workers for backend = "parallel" (default 1). Without effect for backend = "future".

backend

Parallel backend, "future" or "parallel". If NULL (default), "parallel" with one worker is used, i.e. the calculation runs sequentially on every system.

dataRecord

Logical; if TRUE, intermediate results are recorded.

debug.level

Integer controlling verbosity (0 = silent, 2 = detailed output).

seed

Optional integer value for reproducible random numbers.

Details

Stopping criterion

The simulation stops when the coefficient of variation falls below cov_user or when n_max samples are reached. The last batch is reduced so that the total does not exceed n_max.

Parallel execution

The samples of each batch are generated in the master process and split into chunks, which are evaluated in parallel. The workers do not generate random numbers.

  • backend = "future": the chunks are evaluated with future.apply::future_lapply() under the active future plan. The function never changes the plan. The number of workers is determined by the plan, use_threads has no effect and issues a warning if supplied.

  • backend = "parallel": on Unix-like systems parallel::mclapply() with use_threads cores is used. On Windows a PSOCK cluster with use_threads workers is created for the call and stopped afterwards. With use_threads = 1 lapply() is used.

Reproducibility

With a fixed seed the random numbers are generated from a L'Ecuyer-CMRG stream in the master process. The result therefore does not depend on the number of workers. The function sets RNGkind("L'Ecuyer-CMRG") and changes .Random.seed in the global environment.

Value

MC_CRUDE returns a list with the following elements:

  • method: Character string "MC_CRUDE".

  • beta: Estimated reliability index \beta = -\Phi^{-1}(p_f).

  • pf: Estimated probability of failure.

  • var: Estimated variance of the Monte Carlo estimator.

  • cov_mc: Estimated coefficient of variation of pf.

  • cov_user: Target coefficient of variation.

  • n_mc: Total number of Monte Carlo samples generated.

  • n_max: Maximum allowed number of samples.

  • n_batch: Batch size.

  • n_threads: Number of workers used.

  • runtime: CPU time returned by proc.time().

  • data: Data frame with intermediate results (only if dataRecord = TRUE).

Limit-State Function (LSF) Interface

The argument lsf must define a valid limit-state function using one of the following supported signatures:

function(x)

A single numeric vector x containing all basic variables in the order defined in lDistr. Recommended.

function(Z, Fy, M, ...)

Explicitly named scalar arguments corresponding to the variable names defined in the probabilistic model.

The use of function(...) as the sole argument is not supported.

Windows users

On Windows, backend = "future" with future::plan(future::multisession, workers = ...) is recommended. backend = "parallel" creates a new PSOCK cluster for every call.

Author(s)

(C) 2021-2026 K. Nille-Hauf, T. Feiri, M. Ricker, T. Lux – Hochschule Biberach (until 2022), TU Dortmund University - Chair of Structural Concrete (since 2023)

References

Spaethe, G. (1991). Die Sicherheit tragender Baukonstruktionen. Springer.


TesiproV documentation built on Oct. 28, 2026, 5:13 p.m.