romtools.workflows.inverse.vi.gains#
Cross-fitted ACV gains from cached score/weight moments.
Functions
|
Trim accepted samples to the same count limit used for ROM training. |
|
Weighted covariance fit; probabilities enter moments once, not twice. |
|
Balanced, value-independent folds; None selects singleton LOO folds. |
|
Mean/log-std gradient and Hessian kernels at the current target distribution. |
|
|
|
Balance-mixture MIS weights; normalize in log space without clipping. |
|
Fit gains on complementary paired folds, with inner LOO baselines. |
|
Cross-fit stable ACV gains with a fold-only extreme-coefficient guard. |
|
|
|
Solve the ridge fit on the covariance range, excluding numerical nulls. |
|
|
|
|
|
- romtools.workflows.inverse.vi.gains.append_training_batch(batches, batch, limit)[source]#
Trim accepted samples to the same count limit used for ROM training.
- romtools.workflows.inverse.vi.gains.fit_history_gain(high_weights, low_weights, scores, baseline_method, mode, sample_weights=None)[source]#
Weighted covariance fit; probabilities enter moments once, not twice.
- romtools.workflows.inverse.vi.gains.gain_folds(n, num_folds=None)[source]#
Balanced, value-independent folds; None selects singleton LOO folds.
- romtools.workflows.inverse.vi.gains.gaussian_history_kernels(data)[source]#
Mean/log-std gradient and Hessian kernels at the current target distribution.
- romtools.workflows.inverse.vi.gains.importance_weights(samples, target_mean, target_std, target_correlation, batches)[source]#
Balance-mixture MIS weights; normalize in log space without clipping.
- romtools.workflows.inverse.vi.gains.k_fold_acv_estimator(*args, gain_num_folds=5, **kwargs)[source]#
Fit gains on complementary paired folds, with inner LOO baselines.
- romtools.workflows.inverse.vi.gains.loo_acv_estimator(high_weights, low_weights, extra_weights, scores, extra_scores, baseline_method, mode, *, force_unit_gain=False, high_reference_terms=None, epsilon=1e-12, gain_regularization=1.0, return_baselines=False, fixed_gain=None, num_folds=None)[source]#
Cross-fit stable ACV gains with a fold-only extreme-coefficient guard.
num_folds=Noneuses singleton LOO folds; otherwise use balanced contiguous k-fold partitions. Prefix/suffix covariance merges exclude the held-out fold without unstable scatter downdates. Weight offsets are removed before multiplication by scores. The fold containing the reference row is computed separately with a reference from its own fitting set. Moment work remains O(n*p**2); matrix solves are performed once per fold.Ordinary gains are not shrunk toward a preset coefficient. To guard against tiny fitting variances, positive
gain_regularizationlimits scalar/componentwise magnitudes and matrix spectral norms to1 + sqrt(training_count/gain_regularization)/2. The limit grows with sample count; zero disables it. All coefficient decisions exclude the held-out fold and LF-only samples. Matrix coefficients use delta_L @ A.