mcframework.validation.validate_convergence#
- mcframework.validation.validate_convergence(sim: MonteCarloSimulation, n: int, *, sigma_tol: float = 5.0, confidence: float = 0.99, seed: int = 0, **params: Any) ConvergenceReport[source]#
Check that a simulation’s Monte Carlo estimate converges to its analytic reference.
- Parameters:
- sim
MonteCarloSimulation The simulation to validate. Must implement
analytic_reference()to be checkable; otherwise a"no-oracle"report is returned.- n
int Number of simulation draws.
- sigma_tol
float, default 5.0 Tolerance for
ConvergenceReport.within_tol, expressed as a multiple of the standard error. The default of5sigma makes a fixed-seed check essentially non-flaky while still catching real bugs.- confidence
float, default 0.99 Confidence level for the interval used by
ConvergenceReport.within_ci.- seed
int, default 0 Seed applied via
set_seed()for reproducible validation.- **params
Any Forwarded to both
analytic_reference()andrun(), so the oracle and the run use identical parameters.
- sim
- Returns:
ConvergenceReportThe structured outcome.
statusis"no-oracle"when no reference is declared, else"pass"/"fail"based onConvergenceReport.within_tol.
Notes
The oracle is threaded through the stats engine as the context
target(viarun(..., extra_context={"target": oracle})), which also populatesbias_to_target/mse_to_targetin the result for free.