Skip to content

Mixture-proposal importance sampling for Flow estimator#109

Merged
cweniger merged 1 commit into
mainfrom
feature/flow-mixture-importance-sampling
Jun 29, 2026
Merged

Mixture-proposal importance sampling for Flow estimator#109
cweniger merged 1 commit into
mainfrom
feature/flow-mixture-importance-sampling

Conversation

@cweniger

Copy link
Copy Markdown
Owner

Summary

Generalises Flow._importance_sample to draw proposals from a mixture of the conditional and marginal flows instead of a single flow, weighted by the balance heuristic (multiple importance sampling). This is a defensive mixture in Hesterberg's sense: the marginal flow is the broad component that covers the tails the (tempered) conditional under-covers, while the conditional flow gives efficiency near the mode. The mixture density is used as the weight denominator, which bounds the worst-case importance weight and raises the effective sample size (importance_sample:n_eff_min).

What changed

  • New proposal_mixture_beta parameter (default 0.5): fraction of the num_proposals drawn from the conditional flow; the rest are drawn from the marginal flow. Total proposal count is unchanged, so per-call cost is the same.
  • Proposals are pooled from both flows; both log_prob_cond and log_prob_marg are evaluated on the full pooled set (required for the balance heuristic, regardless of which flow drew each sample).
  • Weight denominator is the balance-heuristic mixture density Σ_k (n_k / N) · g_k(θ), computed from the actual sampled counts (exact under rounding).
  • Targets are unchanged: tempered posterior c^{γ/(1+γ)} for proposal mode, importance-corrected posterior c/m for posterior mode.
  • Small unrelated tidy-up: added a log_prefix to the FlowDensity online-norm logger so its metrics are namespaced.

Behaviour / compatibility

  • proposal_mixture_beta=1.0 exactly reproduces the previous single-proposal behaviour in both modes (verified by reduction: log_g_mix → log_prob_cond, so the proposal weight collapses to −1/(1+γ)·log c and the posterior weight to −log m). Use it as a revert switch.
  • The default 0.5 changes sampling results vs. main (this is the intended mixture). Watch importance_sample:n_eff_min — it should increase.

Refs

  • Hesterberg (1995), Weighted Average Importance Sampling and Defensive Mixture Distributions, Technometrics 37(2):185-194.
  • Veach & Guibas (1995), Optimally Combining Sampling Techniques for Monte Carlo Rendering, SIGGRAPH '95 (balance heuristic).

Test plan

  • python -m py_compile falcon/estimators/flow.py
  • Smoke-test a Flow run and confirm n_eff_min is ≥ the beta=1.0 baseline.

🤖 Generated with Claude Code

Replace the single-flow proposal in Flow._importance_sample with a
multiple-importance-sampling mixture of the conditional and marginal
flows, weighted by the balance heuristic (a defensive mixture in
Hesterberg's sense). A new `proposal_mixture_beta` knob controls the
fraction of proposals drawn from the conditional flow; the rest come
from the marginal flow, which provides the broad/defensive coverage of
the tails the (tempered) conditional under-covers. Both densities are
evaluated on the full pooled set and the mixture density is used as the
weight denominator, which bounds the worst-case weight and raises the
effective sample size.

`proposal_mixture_beta=1.0` exactly reproduces the previous
single-proposal behaviour for both posterior and proposal modes; the
default of 0.5 enables an even defensive mixture.

Also add a log_prefix to the FlowDensity online-norm logger so its
metrics are namespaced.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@cweniger cweniger merged commit 90bccbf into main Jun 29, 2026
4 checks passed
@cweniger cweniger deleted the feature/flow-mixture-importance-sampling branch June 29, 2026 18:24
@codecov

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 10.33%. Comparing base (a175353) to head (c7cf168).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
falcon/estimators/flow.py 0.00% 21 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #109      +/-   ##
==========================================
- Coverage   10.38%   10.33%   -0.05%     
==========================================
  Files          30       30              
  Lines        3910     3927      +17     
==========================================
  Hits          406      406              
- Misses       3504     3521      +17     
Flag Coverage Δ
unit 10.33% <0.00%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant