ワンクリックで
debug-sampling
Diagnosing convergence problems, poor acceptance rates, and incorrect results in JNesty.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Diagnosing convergence problems, poor acceptance rates, and incorrect results in JNesty.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
JNesty code architecture — modules, data flow, key data structures, JAX patterns, and demo scripts.
Guide for adding a new bounding method to JNesty.
Guide for adding a new internal sampler (proposal strategy) to JNesty.
JNesty usage guide — public API, parameters, results access, FITS I/O, bounding methods, tuning, and plotting.
| name | /debug-sampling |
| description | Diagnosing convergence problems, poor acceptance rates, and incorrect results in JNesty. |
When investigating sampling issues, always compare with Dynesty first. Dynesty has years of battle-tested optimization. If Dynesty gets the right answer and JNesty doesn't, the issue is in JNesty. If both disagree with theory, the issue may be in the problem setup.
See CLAUDE.md: "Critical Development Principle: Check Dynesty First."
Symptoms: Run hits max_iterations without converging.
Causes:
nlive too low for the problem complexityrwalk_K too small — walker doesn't mix wellbound='none' — walker can't cross between modesmin_eff)Fixes:
nlive (try 2x current)bound='multi' for multi-modal problemsmax_iterationsprior_transform maps correctly to the region of interestmin_eff if Phase 1 is taking too longSymptoms: results['acceptance_rate'] is very low.
Causes:
rwalk_step_scale starting too large — proposals jump too farFixes:
target_acceptance (e.g., 0.3)results['scale_trajectory'] should decrease over timebound='single' or bound='multi' to focus proposalshist_accept/hist_total are reset at bound update boundariesSymptoms: logZ differs from Dynesty by more than combined uncertainty.
Causes:
bound='none')prior_transform (wrong mapping range)format_results() — weight calculation errorInvestigation steps:
delta_logZ_trajectory — should decrease monotonicallyscale_trajectory — should adapt and stabilizeprior_transform with a unit testtotal_calls tracking is correctSymptoms: scale_trajectory is flat or oscillates wildly.
Causes:
target_acceptance vs actual rate)ndim very high — adaptation needs more iterationsFixes:
rwalk_K to get better acceptance estimates per iterationRWalkSampler.tune()hist_accept/hist_total reset at queue drain and bound updatesSymptoms: Phase 1 exits too early or too late.
Causes:
min_eff too high → Phase 1 exits before it shouldmin_ncall too low → Phase 1 exits before live points are well-distributedunit_cube_batch_size too small → slow Phase 1Fixes:
min_eff=10.0 works well for most problemsmin_ncall=2*nlive ensures enough initial explorationunit_cube_batch_size (default 200) for faster Phase 1 on GPUplotting.runplot())plotting.traceplot())plotting.cornerplot() or plotting.cornerpoints())plotting.diagnostics())The demo scripts in dev/demo/ provide a template for comparison:
# Run Dynesty
from dynesty import NestedSampler as DynestyNS
dynesty_sampler = DynestyNS(loglikelihood, prior_transform, ndim=ndim,
nlive=nlive, bound='multi', sample='rwalk')
dynesty_sampler.run_nested(dlogz=0.01)
dynesty_results = dynesty_sampler.results
# Compare
logZ_diff = abs(jnesty_results['logz'] - dynesty_results.logz[-1])
combined_unc = np.sqrt(jnesty_results['logzerr']**2 + dynesty_results.logzerr[-1]**2)
agrees = logZ_diff < combined_unc
Key comparison metrics:
Important: When comparing, ensure Dynesty demos use dlogz=0.01 (not default dlogz=1.0) for fair comparison.
Check n_active in the multi-ellipsoid state:
n_active=1 for a clearly multi-modal posterior, the splitting is too conservativen_active=max_ellipsoids, the splitting is too aggressive (overfitting noise)The BIC criterion in fit_multi_ellipsoid() controls splitting. Adjust max_ellipsoids if needed.
Bound update interval is measured in likelihood calls (not iterations):
bound_update_interval=0: bound fitted once at start, never updated. Fast but may miss evolving posterior shape.bound_update_interval=rwalk_K*nlive (default for multi): ~nlive iterations between updates. Good balance.rwalk_K*nlive.If the queue never drains, scale won't adapt. This happens when:
queue_size is too large relative to iteration countScale adapts only at queue drain in queue mode. If queue_size is very large, adaptation will be infrequent. Check:
queue_size=8 (default) is Dynesty's multiprocessing default# Syntax check after code changes
python -m py_compile src/jnesty/internal_samplers.py
python -m py_compile src/jnesty/bounding.py
python -m py_compile src/jnesty/sampler.py
python -m py_compile src/jnesty/jnesty.py
# Run unit tests
pytest tests/unit/test_queue_mode.py -v
pytest tests/integration/test_queue_and_defaults.py -v
# Run a quick demo
python dev/demo/01_multimodal_gaussian_mixture_jnesty.py
# Import check
python -c "from jnesty import NestedSampler, save_results, load_results; print('OK')"