compute_weight_update: Internal weight accumulation for Monte Carlo Importance...

View source: R/mc_is_system.R

compute_weight_updateR Documentation

Internal weight accumulation for Monte Carlo Importance Sampling (System Case)

Description

Internal helper used by 'MC_IS_system()' to accumulate the importance sampling sums that are needed for the standard estimator

\hat{p}_f = \frac{1}{n}\sum_i I_i w_i, \qquad \widehat{\mathrm{Var}}(\hat{p}_f) = \frac{1}{n}\left(\frac{1}{n}\sum_i I_i w_i^2 - \hat{p}_f^2\right).

Both sums are accumulated in the log domain (log-sum-exp), so that very large or very small weights cannot overflow or underflow.

Usage

compute_weight_update(
  all_log_w,
  all_I_vals,
  stability_mode = NULL,
  sys_type = NULL,
  state
)

Arguments

all_log_w

Numeric vector of log-weights for the current batch.

all_I_vals

Numeric vector of failure indicators (0/1).

stability_mode, sys_type

Not used any more. Kept for compatibility of the call signature.

state

List containing the current accumulated sums:

log_sum_Iw

Log of the cumulative sum of the failure weights.

log_sum_Iw2

Log of the cumulative sum of the squared failure weights.

n_sim

Total number of samples processed.

Details

This function is internal and not intended to be called directly by users.

Value

Updated 'state' list.


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