public double mergeValueInLogSpace(
     RealParameter removed, RealParameter merge, ParametricDistribution distr) throws Exception {
   double val1 = Math.log(removed.getValue());
   double val2 = Math.log(merge.getValue());
   double x = val1 - val2;
   return distr.calcLogP(new RealParameter(new Double[] {x})) - val1;
 }
  public double mergeValue(RealParameter removed, RealParameter merge, ParametricDistribution distr)
      throws Exception {
    Double[] x = new Double[removed.getDimension()];
    for (int i = 0; i < x.length; i++) {
      x[i] = removed.getValue(i) - merge.getValue(i);
    }

    return distr.calcLogP(new RealParameter(x));
  }
  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);
  }
  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));
  }