In sampler_CRP, if a user sets the max number of clusters to be less than the number of "observations", then we warn the user that that max number is exceeded and simply avoid setting the cluster membership value to be more than the max number.
However, when this happens it turns out that our logic for restoring values of marginalizedNodes when they are sampled by the non-conjugate sampler is faulty but no cluster is opened with those cluster parameter values. When we are at the max, no sampling of the marginalizedNodes is done, so the call to sample(i,0) resets values of an arbitrary index to arbitrary values (the last stored index and values). This will presumably cause incorrect sampling. Fortunately, this is in a case where we have already warned the user they should increase the max number of clusters, so the MCMC output is already invalid (albeit as an incorrectly constrained model rather than incorrect samples per se).
In
sampler_CRP
, if a user sets the max number of clusters to be less than the number of "observations", then we warn the user that that max number is exceeded and simply avoid setting the cluster membership value to be more than the max number.However, when this happens it turns out that our logic for restoring values of marginalizedNodes when they are sampled by the non-conjugate sampler is faulty but no cluster is opened with those cluster parameter values. When we are at the max, no sampling of the marginalizedNodes is done, so the call to
sample(i,0)
resets values of an arbitrary index to arbitrary values (the last stored index and values). This will presumably cause incorrect sampling. Fortunately, this is in a case where we have already warned the user they should increase the max number of clusters, so the MCMC output is already invalid (albeit as an incorrectly constrained model rather than incorrect samples per se).I will fix this shortly.