public double proposeDiscreteValue( QuietRealParameter proposal, double oldValue, ConditionalCategoricalDistribution distr, double upper, double lower) { int oldModel = (int) oldValue; double newValue = Randomizer.randomChoicePDF(distr.conditionalDensities(oldModel)) + distr.getOffset(); proposal.setValueQuietly(0, newValue); proposal.setBounds(lower, upper); return distr.logConditionalDensity(oldModel, (int) newValue); }
public double proposeNewValueInLogSpace( QuietRealParameter proposal, double oldValue, ParametricDistribution distr, double upper, double lower) throws Exception { double sampleVal = distr.sample(1)[0][0]; double newValue = Math.exp(sampleVal + Math.log(oldValue)); proposal.setValueQuietly(0, newValue); proposal.setBounds(lower, upper); return distr.calcLogP(new QuietRealParameter(new Double[] {sampleVal})) - Math.log(newValue); }