コード例 #1
0
  public QuietRealParameter getSample(ParametricDistribution distr, double upper, double lower)
      throws Exception {

    Double[][] sampleVals = distr.sample(1);

    QuietRealParameter sampleParameter = new QuietRealParameter(sampleVals[0]);
    sampleParameter.setUpper(upper);
    sampleParameter.setLower(lower);

    return sampleParameter;
  }
コード例 #2
0
  private double proposeNewValue(
      QuietRealParameter proposal, ParametricDistribution distr, double upper, double lower)
      throws Exception {
    Double[] sampleVals = distr.sample(1)[0];
    for (int i = 0; i < sampleVals.length; i++) {
      proposal.setValueQuietly(i, sampleVals[i]);
    }
    proposal.setUpper(upper);
    proposal.setLower(lower);

    return distr.calcLogP(new QuietRealParameter(sampleVals));
  }
コード例 #3
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);
  }
コード例 #4
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));
  }
コード例 #5
0
  public double proposalValueInLogSpace(
      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);

    /*System.out.println("oldValue: "+oldValue+", newVal: "+newValue+", logpdf: "+(distr.calcLogP(new QuietRealParameter(new Double[]{sampleVal}))-Math.log(newValue)));
    System.out.println("sampleValue: "+sampleVal);
    System.out.println(distr.calcLogP(new QuietRealParameter(new Double[]{sampleVal})));*/

    // System.out.println(oldValue+" "+newValue);
    return distr.calcLogP(new QuietRealParameter(new Double[] {sampleVal})) - Math.log(newValue);
  }