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; }
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)); }
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)); }
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); }