gpt4 book ai didi

org.apache.commons.math3.distribution.ZipfDistribution.sample()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 07:44:49 27 4
gpt4 key购买 nike

本文整理了Java中org.apache.commons.math3.distribution.ZipfDistribution.sample()方法的一些代码示例,展示了ZipfDistribution.sample()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipfDistribution.sample()方法的具体详情如下:
包路径:org.apache.commons.math3.distribution.ZipfDistribution
类名称:ZipfDistribution
方法名:sample

ZipfDistribution.sample介绍

暂无

代码示例

代码示例来源:origin: org.apache.commons/commons-math3

/**
 * Generates a random value from the {@link ZipfDistribution Zipf Distribution}.
 *
 * @param numberOfElements the number of elements of the ZipfDistribution
 * @param exponent the exponent of the ZipfDistribution
 * @return random value sampled from the Zipf(numberOfElements, exponent) distribution
 * @exception NotStrictlyPositiveException if {@code numberOfElements <= 0}
 * or {@code exponent <= 0}.
 */
public int nextZipf(int numberOfElements, double exponent) throws NotStrictlyPositiveException {
  return new ZipfDistribution(getRandomGenerator(), numberOfElements, exponent).sample();
}

代码示例来源:origin: apache/kylin

protected String prepareTestDate() throws IOException {
  String[] allKeys = new String[KEY_SPACE];
  for (int i = 0; i < KEY_SPACE; i++) {
    allKeys[i] = RandomStringUtils.randomAlphabetic(10);
  }
  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);
  Writer fw = new OutputStreamWriter(new FileOutputStream(tempFile), StandardCharsets.UTF_8);
  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();
}

代码示例来源:origin: johnlpage/POCDriver

private int getNextVal(int mult) {
  int rval;
  if (zipfian) {
    rval = zipf.sample();
  } else {
    rval = (int) Math.abs(Math.floor(rng.nextDouble() * mult));
  }
  return rval;
}

代码示例来源:origin: Netflix/ndbench

@Override
  public String getNextKey() {
    int keyIndex = zipf.sample();
    if (isPreLoadKeys()) {
      return keys.get(keyIndex);
    } else {
      return "T" + keyIndex;
    }
  }
}

代码示例来源:origin: com.netflix.ndbench/ndbench-core

@Override
  public String getNextKey() {
    int keyIndex = zipf.sample();
    if (isPreLoadKeys()) {
      return keys.get(keyIndex);
    } else {
      return "T" + keyIndex;
    }
  }
}

代码示例来源:origin: geogebra/geogebra

/**
 * Generates a random value from the {@link ZipfDistribution Zipf Distribution}.
 *
 * @param numberOfElements the number of elements of the ZipfDistribution
 * @param exponent the exponent of the ZipfDistribution
 * @return random value sampled from the Zipf(numberOfElements, exponent) distribution
 * @exception NotStrictlyPositiveException if {@code numberOfElements <= 0}
 * or {@code exponent <= 0}.
 */
public int nextZipf(int numberOfElements, double exponent) throws NotStrictlyPositiveException {
  return new ZipfDistribution(getRandomGenerator(), numberOfElements, exponent).sample();
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

/**
 * Generates a random value from the {@link ZipfDistribution Zipf Distribution}.
 *
 * @param numberOfElements the number of elements of the ZipfDistribution
 * @param exponent the exponent of the ZipfDistribution
 * @return random value sampled from the Zipf(numberOfElements, exponent) distribution
 * @exception NotStrictlyPositiveException if {@code numberOfElements <= 0}
 * or {@code exponent <= 0}.
 */
public int nextZipf(int numberOfElements, double exponent) throws NotStrictlyPositiveException {
  return new ZipfDistribution(getRandomGenerator(), numberOfElements, exponent).sample();
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com