nimble-dev / nimble

The base NIMBLE package for R
http://R-nimble.org
BSD 3-Clause "New" or "Revised" License
160 stars 24 forks source link

catch case of discrete (integer) target with only one viable next value #1501

Open perrydv opened 1 month ago

perrydv commented 1 month ago

... when at modal value.

danielturek commented 1 month ago

@perrydv I'm pushing minor cleanup to this, but the logic looks sound.

This is a good patch to have - and I'm also fairly surprised we've never encountered this before.

Also, a push will re-trigger testing, to see if the previous failure with the PG sampler is (perhaps?) intermittant?

perrydv commented 1 month ago

Thanks @danielturek . Would you also be up for making the changes in sampler_slice_noncentered?

I have not investigated the test failures in detail. The one in test-polyagamma looks like it might be a simple monte carlo tolerance issue, where if we inspect and trust the (very slightly different from previous) result we can tweak the tolerance for the test to pass. The test-mcmc failures is a case where gold-file results for a slice sampler example (line 336 of test-mcmc) are no longer matched. That makes sense too. However, superficially the numbers look a bit more meaningfully different, so we'd have to look at whether this is expected to be a well mixed, converged result, etc and decide whether we are confident updating the gold file. Do you want to look at these? Noting for @paciorek too.

danielturek commented 4 weeks ago

@perrydv I've made similar changes to the slice_noncentered sampler.

Do you have a test case that triggers this error (with contractions to a single integer), which we could add into the MCMC testing?

In any case, the MCMC testing gold file looks like it will need to be updated.