コード例 #1
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);
  }
コード例 #2
0
  private double proposeNewValue(
      QuietRealParameter proposal,
      Double[] oldValues,
      ParametricDistribution distr,
      double upper,
      double lower)
      throws Exception {

    Double[] sampleVals = distr.sample(1)[0];
    for (int i = 0; i < sampleVals.length; i++) {
      // if(distr instanceof DiracDeltaDistribution)
      // System.out.println(distr.getClass());
      proposal.setValueQuietly(i, oldValues[i] + sampleVals[i]);
    }
    proposal.setUpper(upper);
    proposal.setLower(lower);

    return distr.calcLogP(new QuietRealParameter(sampleVals));
  }