本文整理汇总了Java中dr.math.EmpiricalBayesPoissonSmoother类的典型用法代码示例。如果您正苦于以下问题:Java EmpiricalBayesPoissonSmoother类的具体用法?Java EmpiricalBayesPoissonSmoother怎么用?Java EmpiricalBayesPoissonSmoother使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EmpiricalBayesPoissonSmoother类属于dr.math包,在下文中一共展示了EmpiricalBayesPoissonSmoother类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doSmoothing
import dr.math.EmpiricalBayesPoissonSmoother; //导入依赖的package包/类
private void doSmoothing(double[] in) {
double meanX = DiscreteStatistics.mean(in);
double varX = DiscreteStatistics.variance(in);
System.err.println("Original mean: " + meanX);
System.err.println("Original var : " + varX + "\n");
double[] out = EmpiricalBayesPoissonSmoother.smooth(in);
double meanY = DiscreteStatistics.mean(out);
double varY = DiscreteStatistics.variance(out);
System.err.println("Smoothed mean: " + meanY);
System.err.println("Smoothed var : " + varY);
System.err.println("");
assertEquals(meanX, meanY, tolerance);
assertTrue(varY <= varX);
}
示例2: performSmoothing
import dr.math.EmpiricalBayesPoissonSmoother; //导入依赖的package包/类
private double[][][] performSmoothing(double[][][] allSamples) {
double[][][] smoothedArray = new double[allSamples.length][][];
double[][][] transpose = new double[allSamples.length][][];
for (int i = 0; i < allSamples.length; i++) {
transpose[i] = transpose(allSamples[i]); // transpose means: [allSamples][site]
for (int sample = 0; sample < numSamples; ++sample) {
transpose[i][sample] = EmpiricalBayesPoissonSmoother.smooth(transpose[i][sample]);
}
smoothedArray[i] = transpose(transpose[i]);
}
return smoothedArray;
}
示例3: doSmoothing
import dr.math.EmpiricalBayesPoissonSmoother; //导入依赖的package包/类
private void doSmoothing() {
if (cachedValues == null) {
cachedValues = new double[NUM_TRAITS][];
}
for (int i = 0; i < NUM_TRAITS; i++) {
if (useSmoothing) {
cachedValues[i] = EmpiricalBayesPoissonSmoother.smooth((double[]) traits[i].getTrait(tree, tree.getRoot()));
} else {
cachedValues[i] = (double[]) traits[i].getTrait(tree, tree.getRoot());
}
}
}
示例4: testSmooth
import dr.math.EmpiricalBayesPoissonSmoother; //导入依赖的package包/类
@Test
public void testSmooth() throws Exception {
final double[] arr = new double[] {0, 1, 3, 0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 3, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 4, 1, 0, 0, 1, 0, 0, 1, 0, 0, 2, 1, 0, 0, 1, 2, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 2, 1, 1, 0, 0, 0, 0, 0, 1, 1, 2, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 2, 0, 3, 1, 0, 0, 0, 0, 2, 0, 0, 1, 3, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 3, 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, 0, 1, 1, 1, 0, 0, 2, 2, 3, 0, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 2, 0, 0, 0, 1, 0, 0, 6, 1, 0, 3, 1, 1, 3, 0, 2, 0, 1, 0, 0, 0, 2, 1, 4, 1, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 1, 0, 0, 1, 1, 5, 0, 0, 2, 0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0, 0, 0, 0, 0, 1, 3, 0, 0, 0, 0, 0, 0, 2, 2, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1};
final double[] t = Doubles.constantArray(arr.length, 1.0);
final double largeT = 10.0;
final double mean = StatUtils.mean(arr);
final double var = StatUtils.variance(arr);
final double mom_alpha = (mean * mean) / (var - mean),
mom_beta = mean / (var - mean);
final double[] result = TLambdaPoissonSmoother.estimateAlphaBeta(arr, t).getPointRef();
final double[] resultBl = TLambdaPoissonSmoother.estimateAlphaBeta(arr, Doubles.constantArray(t.length, largeT)).getPointRef();
// Larger branch length just changes Beta
Assert.assertEquals(result[0], resultBl[0], 1e-2);
Assert.assertEquals(result[1], resultBl[1] / largeT, 1e-2);
// Actual results are close to MOM result
Assert.assertEquals(mom_alpha, result[0], TOL);
Assert.assertEquals(mom_beta, result[1], TOL);
final double[] tlSmoothed = TLambdaPoissonSmoother.smooth(arr, t);
final double[] tlSmoothedBl = TLambdaPoissonSmoother.smooth(arr, Doubles.constantArray(t.length, largeT));
Assert.assertArrayEquals(tlSmoothed, Doubles.scalarMultiply(tlSmoothedBl, largeT), 1e2);
final double[] origSmoothed = EmpiricalBayesPoissonSmoother.smooth(arr);
// this is a pretty loose tolerance...
Assert.assertArrayEquals(origSmoothed, tlSmoothed, 0.1);
}
示例5: CnCsToDnDsPerSiteAnalysis
import dr.math.EmpiricalBayesPoissonSmoother; //导入依赖的package包/类
public CnCsToDnDsPerSiteAnalysis(TraceList traceListN, TraceList traceListS) {
this.traceListN = traceListN;
this.traceListS = traceListS;
this.numSites = (traceListN.getTraceCount()) / 2;
this.format = new OutputFormat();
setUseSample(false);
double[][] allCn = new double[numSites][this.traceListN.getStateCount()];
double[][] allUn = new double[numSites][this.traceListN.getStateCount()];
double[][] allCs = new double[numSites][this.traceListS.getStateCount()];
double[][] allUs = new double[numSites][this.traceListS.getStateCount()];
for (int o = 0; o < numSites; o++) {
allCn[o] = listToDoubleArray(traceListN.getValues(o));
allUn[o] = listToDoubleArray(traceListN.getValues(numSites + o));
allCs[o] = listToDoubleArray(traceListS.getValues(o));
allUs[o] = listToDoubleArray(traceListS.getValues(numSites + o));
}
allCn = transpose(allCn);
allUn = transpose(allUn);
allCs = transpose(allCs);
allUs = transpose(allUs);
double[][] tempAllSmoothedCn = new double[this.traceListN.getStateCount()][numSites];
double[][] tempAllSmoothedUn = new double[this.traceListN.getStateCount()][numSites];
double[][] tempAllSmoothedCs = new double[this.traceListS.getStateCount()][numSites];
double[][] tempAllSmoothedUs = new double[this.traceListS.getStateCount()][numSites];
boolean first = true;
for (int p = 0; p < this.traceListN.getStateCount(); p++) {
// Testing code:
// if (first) {
// tempAllSmoothedCn[p] = EmpiricalBayesPoissonSmoother.smooth(allCn[p]);
// System.err.println("Smooth values: " + new Vector(tempAllSmoothedCn[p]));
//
// tempAllSmoothedCn[p] = EmpiricalBayesPoissonSmoother.smoothWithSample(allCn[p]);
// System.err.println("Sample values: " + new Vector(tempAllSmoothedCn[p]));
// first = false;
// }
// System.exit(-1);
if (format.useSample) {
tempAllSmoothedCn[p] = EmpiricalBayesPoissonSmoother.smoothWithSample(allCn[p]);
tempAllSmoothedUn[p] = EmpiricalBayesPoissonSmoother.smoothWithSample(allUn[p]);
tempAllSmoothedCs[p] = EmpiricalBayesPoissonSmoother.smoothWithSample(allCs[p]);
tempAllSmoothedUs[p] = EmpiricalBayesPoissonSmoother.smoothWithSample(allUs[p]);
} else {
tempAllSmoothedCn[p] = EmpiricalBayesPoissonSmoother.smooth(allCn[p]);
tempAllSmoothedUn[p] = EmpiricalBayesPoissonSmoother.smooth(allUn[p]);
tempAllSmoothedCs[p] = EmpiricalBayesPoissonSmoother.smooth(allCs[p]);
tempAllSmoothedUs[p] = EmpiricalBayesPoissonSmoother.smooth(allUs[p]);
}
}
allSmoothedCn = transpose(tempAllSmoothedCn);
allSmoothedUn = transpose(tempAllSmoothedUn);
allSmoothedCs = transpose(tempAllSmoothedCs);
allSmoothedUs = transpose(tempAllSmoothedUs);
fieldWidth = 14;
firstField = 10;
numberFormatter = new NumberFormatter(6);
numberFormatter.setPadding(true);
numberFormatter.setFieldWidth(fieldWidth);
}