/** * Runs multiple independently-seeded [MCMC]{@link ran.mc.MCMC} chains from the same target and * computes the [Gelman-Rubin]{@link ran.mc.gelmanRubin} convergence diagnostic across them — the * recommended workflow for gating MCMC convergence (decisions/0024-mcmc-warmup-convergence-strategy.md), * since no signal computable from a single chain can distinguish "converged" from "stuck". * `samplerOptions` is forwarded to `new Sampler(samplerOptions)` without inspecting its keys, so any * `MCMC` subclass — including `Gibbs`, whose options object has no `logDensity` at all — can * drive the diagnostic the same way (decisions/0033-generalized-runchains-sampler-driver.md). * * Do not pass an explicit `initialState.x`. The same `samplerOptions` object is * forwarded to every chain, and `MCMC.seed()` only redraws the starting position when `x` was * not supplied. If you provide `initialState.x`, all chains start from the identical point, * which defeats the over-dispersed-initialization that makes the Gelman-Rubin diagnostic * meaningful — a chain family stuck in one mode then reports R-hat ≈ 1 ("converged") because every * chain is stuck in the same place. Omit `initialState.x` so each seed draws its own random start. * * @method runChains * @memberof ran.mc * @param {Function} Sampler An [MCMC]{@link ran.mc.MCMC} subclass (e.g. [RWM]{@link ran.mc.RWM}, * [AdaptiveMetropolis]{@link ran.mc.AdaptiveMetropolis}, [Slice]{@link ran.mc.Slice}, * [Gibbs]{@link ran.mc.Gibbs}, [HMC]{@link ran.mc.HMC}, [MALA]{@link ran.mc.MALA}, or * [NUTS]{@link ran.mc.NUTS}) to drive each chain. * @param {Object=} samplerOptions Options object forwarded verbatim to `new Sampler(samplerOptions)` * for every chain — the same shape that sampler's own options-object constructor accepts (e.g. * `{logDensity, config, initialState}` for RWM/AdaptiveMetropolis/Slice, `{logDensity, * gradLogDensity, config, initialState}` for HMC/MALA/NUTS, `{conditionals, config, initialState}` * for Gibbs). * @param {Object=} runOptions Run configuration. Supported properties: *