/// Test sampling /*[Test] -- assertChiSquareAccept not ported*/ public void testSampling() { int[] densityPoints = makeDensityTestPoints(); double[] densityValues = makeDensityTestValues(); int sampleSize = 1000; int length = eliminateZeroMassPoints(densityPoints, densityValues);//TestUtils AbstractIntegerDistribution distribution = (AbstractIntegerDistribution)makeDistribution(); double[] expectedCounts = new double[length]; long[] observedCounts = new long[length]; for (int i = 0; i < length; i++) { expectedCounts[i] = sampleSize * densityValues[i]; } distribution.reseedRandomGenerator(1000); // Use fixed seed int[] sample = distribution.sample(sampleSize); for (int i = 0; i < sampleSize; i++) { for (int j = 0; j < length; j++) { if (sample[i] == densityPoints[j]) { observedCounts[j]++; } } } // NOT PORTED: //TestUtils.assertChiSquareAccept(densityPoints, expectedCounts, observedCounts, .001); }
public virtual void tearDown() { distribution = null; densityTestPoints = null; densityTestValues = null; logDensityTestValues = null; cumulativeTestPoints = null; cumulativeTestValues = null; inverseCumulativeTestPoints = null; inverseCumulativeTestValues = null; }
public virtual void setUp() { distribution = makeDistribution(); densityTestPoints = makeDensityTestPoints(); densityTestValues = makeDensityTestValues(); logDensityTestValues = makeLogDensityTestValues(); cumulativeTestPoints = makeCumulativeTestPoints(); cumulativeTestValues = makeCumulativeTestValues(); inverseCumulativeTestPoints = makeInverseCumulativeTestPoints(); inverseCumulativeTestValues = makeInverseCumulativeTestValues(); }
/// @param distribution The distribution to set. protected void setDistribution(AbstractIntegerDistribution distribution) { this.distribution = distribution; }