Implement maximum step limits and acceptance handling for slice sampling #35
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements maximum iteration limits and acceptance handling for slice sampling to address infinite loop issues and improve robustness.
Changes
Core Implementation
max_steps
(stepping-out) andmax_shrinkage
(shrinking) parameters following Radford Neal's slice sampling algorithmis_accepted
boolean inSliceInfo
and proper acceptance logic usingstatic_binomial_sampling
Parameter Improvements
max_steps
andmax_shrinkage
for claritymax_steps=10
,max_shrinkage=100
across both slice sampling and nested slice samplingstep_body_fun
/step_cond_fun
andshrink_body_fun
/shrink_cond_fun
Nested Sampling Integration
build_kernel
andas_top_level_api
) now accept step limit parametersIssues Addressed
Closes #20 - Slice sampler infinite loop in horizontal_slice function
Closes #23 - Add max iterations limit to slice sampler while loops
max_steps
andmax_shrinkage
parametersCloses #32 - Add acceptance boolean to slice sampling for handling failure modes
is_accepted
boolean inSliceInfo
with proper acceptance/rejection logicstatic_binomial_sampling
following BlackJAX patterns from other MCMC methodsImplementation Details
Maximum Step Logic
j
andk
counters limit expansion in each directions_steps < max_shrinkage + 1
condition to allow exactlymax_shrinkage
attemptsBackward Compatibility
m
parameter kept inhorizontal_slice
to maintain Neal's notationTesting
This implementation has been tested to ensure:
max_shrinkage=1
works correctly (previously failed)🤖 Generated with Claude Code
Co-Authored-By: Claude [email protected]