コード例 #1
0
 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);
 }
コード例 #2
0
  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);
  }