RandomDataGenerator implements RandomData, Serializable { public int nextZipf(int numberOfElements, double exponent) throws NotStrictlyPositiveException { return new ZipfDistribution(getRandomGenerator(), numberOfElements, exponent).sample(); } RandomDataGenerator();  RandomDataGenerator(RandomGenerator rand); String nextHexString(int len); int nextInt(final int lower, final int upper); long nextLong(final long lower, final long upper); String nextSecureHexString(int len); int nextSecureInt(final int lower, final int upper); long nextSecureLong(final long lower, final long upper); long nextPoisson(double mean); double nextGaussian(double mu, double sigma); double nextExponential(double mean); double nextGamma(double shape, double scale); int nextHypergeometric(int populationSize, int numberOfSuccesses, int sampleSize); int nextPascal(int r, double p); double nextT(double df); double nextWeibull(double shape, double scale); int nextZipf(int numberOfElements, double exponent); double nextBeta(double alpha, double beta); int nextBinomial(int numberOfTrials, double probabilityOfSuccess); double nextCauchy(double median, double scale); double nextChiSquare(double df); double nextF(double numeratorDf, double denominatorDf); double nextUniform(double lower, double upper); double nextUniform(double lower, double upper, boolean lowerInclusive); int[] nextPermutation(int n, int k); Object[] nextSample(Collection<?> c, int k); void reSeed(long seed); void reSeedSecure(); void reSeedSecure(long seed); void reSeed(); void setSecureAlgorithm(String algorithm, String provider); RandomGenerator getRandomGenerator();  }
@Test public void testNextZipf() { ZipfDistributionTest testInstance = new ZipfDistributionTest(); int[] densityPoints = testInstance.makeDensityTestPoints(); double[] densityValues = testInstance.makeDensityTestValues(); int sampleSize = 1000; int length = TestUtils.eliminateZeroMassPoints(densityPoints, densityValues); ZipfDistribution distribution = (ZipfDistribution) testInstance.makeDistribution(); double[] expectedCounts = new double[length]; long[] observedCounts = new long[length]; for (int i = 0; i < length; i++) { expectedCounts[i] = sampleSize * densityValues[i]; } randomData.reSeed(1000); for (int i = 0; i < sampleSize; i++) { int value = randomData.nextZipf(distribution.getNumberOfElements(), distribution.getExponent()); for (int j = 0; j < length; j++) { if (value == densityPoints[j]) { observedCounts[j]++; } } } TestUtils.assertChiSquareAccept(densityPoints, expectedCounts, observedCounts, .001); }