List of usage examples for org.apache.commons.math3.distribution ZipfDistribution sample
public int sample()
From source file:org.apache.accumulo.core.file.rfile.RolllingStatsTest.java
@Test public void testZipf() { ZipfDistribution zd = new ZipfDistribution(new Well19937c(42), 1000, 2); testDistribrution(() -> zd.sample() * 100); }
From source file:org.apache.kylin.measure.topn.TopNCounterTest.java
protected String prepareTestDate() throws IOException { String[] allKeys = new String[KEY_SPACE]; for (int i = 0; i < KEY_SPACE; i++) { allKeys[i] = RandomStringUtils.randomAlphabetic(10); }//from w ww . ja v a 2s. com outputMsg("Start to create test random data..."); long startTime = System.currentTimeMillis(); ZipfDistribution zipf = new ZipfDistribution(KEY_SPACE, 0.5); int keyIndex; File tempFile = File.createTempFile("ZipfDistribution", ".txt"); if (tempFile.exists()) FileUtils.forceDelete(tempFile); FileWriter fw = new FileWriter(tempFile); try { for (int i = 0; i < TOTAL_RECORDS; i++) { keyIndex = zipf.sample() - 1; fw.write(allKeys[keyIndex]); fw.write('\n'); } } finally { if (fw != null) fw.close(); } outputMsg("Create test data takes : " + (System.currentTimeMillis() - startTime) / 1000 + " seconds."); outputMsg("Test data in : " + tempFile.getAbsolutePath()); return tempFile.getAbsolutePath(); }