gpt4 book ai didi

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

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

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

ZipfDistribution.<init>介绍

[英]Create a new Zipf distribution with the given number of elements and exponent.

Note: this constructor will implicitly create an instance of Well19937c as random generator to be used for sampling only (see #sample() and #sample(int)). In case no sampling is needed for the created distribution, it is advised to pass nullas random generator via the appropriate constructors to avoid the additional initialisation overhead.
[中]用给定的元素数和指数创建一个新的Zipf分布。
注意:此构造函数将隐式创建Well19937c的实例作为随机生成器,仅用于采样(请参见#sample()和#sample(int))。如果创建的分布不需要采样,建议通过适当的构造函数传递nullas random generator,以避免额外的初始化开销。

代码示例

代码示例来源: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: apache/incubator-druid

Integer startInt = schema.getStartInt();
cardinality = schema.getEndInt() - startInt;
ZipfDistribution zipf = new ZipfDistribution(cardinality, schema.getZipfExponent());
for (int i = 0; i < cardinality; i++) {
 probabilities.add(new Pair<>((Object) (i + startInt), zipf.probability(i)));
ZipfDistribution zipf = new ZipfDistribution(enumeratedValues.size(), schema.getZipfExponent());
for (int i = 0; i < cardinality; i++) {
 probabilities.add(new Pair<>(enumeratedValues.get(i), zipf.probability(i)));

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

public ZipfianStringKeyGenerator(boolean preLoadKeys, int numKeys, double exponent) {
  super(numKeys, preLoadKeys);
  this.zipf = new ZipfDistribution(numKeys, exponent);
}

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

public ZipfianStringKeyGenerator(boolean preLoadKeys, int numKeys, double exponent) {
  super(numKeys, preLoadKeys);
  this.zipf = new ZipfDistribution(numKeys, exponent);
}

代码示例来源:origin: org.apache.solr/solr-solrj

@Override
 public Object doWork(Object first, Object second) throws IOException{
  if(null == first){
   throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - null found for the first value",toExpression(constructingFactory)));
  }
  if(null == second){
   throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - null found for the second value",toExpression(constructingFactory)));
  }

  Number size = (Number)first;
  Number exp = (Number)second;

  return new ZipfDistribution(size.intValue(), exp.doubleValue());
 }
}

代码示例来源: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();
}

代码示例来源: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: geogebra/geogebra

/**
 * @param param
 *            number of elements
 * @param param2
 *            exponent
 * @return Zipf distribution
 */
ZipfDistribution getZipfDistribution(int param, double param2) {
  if (zipf == null || zipf.getNumberOfElements() != param
      || zipf.getExponent() != param2) {
    zipf = new ZipfDistribution(param, param2);
  }
  return zipf;
}

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

if (testOpts.zipfian) {
  zipfian = true;
  zipf = new ZipfDistribution(testOpts.zipfsize, 0.99);

代码示例来源:origin: org.apache.beam/beam-sdks-java-io-synthetic

"The multiplier of the Zipf distribution should be >= 0, but found %s.",
  multiplier);
final ZipfDistribution dist = new ZipfDistribution(100, param);
return scaledSampler(fromIntegerDistribution(dist), multiplier);

代码示例来源:origin: org.apache.beam/beam-sdks-java-io-synthetic

@Before
public void setUp() {
 testSourceOptions.splitPointFrequencyRecords = 1;
 testSourceOptions.numRecords = 10;
 testSourceOptions.keySizeBytes = 10;
 testSourceOptions.valueSizeBytes = 20;
 testSourceOptions.numHotKeys = 3;
 testSourceOptions.hotKeyFraction = 0.3;
 testSourceOptions.setSeed(123456);
 testSourceOptions.bundleSizeDistribution =
   fromIntegerDistribution(new ZipfDistribution(100, 2.5));
 testSourceOptions.forceNumInitialBundles = null;
}

代码示例来源:origin: org.apache.accumulo/accumulo-test

ZipfDistribution zdiBanks = new ZipfDistribution((Integer) state.get("numBanks"), 1);
String bank = Utils.getBank(zdiBanks.inverseCumulativeProbability(rand.nextDouble()));
ZipfDistribution zdiAccts = new ZipfDistribution(numAccts, 1);
String acct1 = Utils.getAccount(zdiAccts.inverseCumulativeProbability(rand.nextDouble()));
String acct2 = Utils.getAccount(zdiAccts.inverseCumulativeProbability(rand.nextDouble()));

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

dist = new ZipfDistribution(n, p);

代码示例来源:origin: deeplearning4j/Arbiter

@Override
  public IntegerDistribution deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
    JsonNode node = p.getCodec().readTree(p);
    String simpleName = node.get("distribution").asText();

    switch (simpleName) {
      case "BinomialDistribution":
        return new BinomialDistribution(node.get("trials").asInt(), node.get("p").asDouble());
      case "GeometricDistribution":
        return new GeometricDistribution(node.get("p").asDouble());
      case "HypergeometricDistribution":
        return new HypergeometricDistribution(node.get("populationSize").asInt(),
                node.get("numberOfSuccesses").asInt(), node.get("sampleSize").asInt());
      case "PascalDistribution":
        return new PascalDistribution(node.get("r").asInt(), node.get("p").asDouble());
      case "PoissonDistribution":
        return new PoissonDistribution(node.get("p").asDouble());
      case "UniformIntegerDistribution":
        return new UniformIntegerDistribution(node.get("lower").asInt(), node.get("upper").asInt());
      case "ZipfDistribution":
        return new ZipfDistribution(node.get("numElements").asInt(), node.get("exponent").asDouble());
      default:
        throw new RuntimeException("Unknown or not supported distribution: " + simpleName);
    }
  }
}

代码示例来源:origin: org.deeplearning4j/arbiter-core

@Override
  public IntegerDistribution deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
    JsonNode node = p.getCodec().readTree(p);
    String simpleName = node.get("distribution").asText();

    switch (simpleName) {
      case "BinomialDistribution":
        return new BinomialDistribution(node.get("trials").asInt(), node.get("p").asDouble());
      case "GeometricDistribution":
        return new GeometricDistribution(node.get("p").asDouble());
      case "HypergeometricDistribution":
        return new HypergeometricDistribution(node.get("populationSize").asInt(),
                node.get("numberOfSuccesses").asInt(), node.get("sampleSize").asInt());
      case "PascalDistribution":
        return new PascalDistribution(node.get("r").asInt(), node.get("p").asDouble());
      case "PoissonDistribution":
        return new PoissonDistribution(node.get("p").asDouble());
      case "UniformIntegerDistribution":
        return new UniformIntegerDistribution(node.get("lower").asInt(), node.get("upper").asInt());
      case "ZipfDistribution":
        return new ZipfDistribution(node.get("numElements").asInt(), node.get("exponent").asDouble());
      default:
        throw new RuntimeException("Unknown or not supported distribution: " + simpleName);
    }
  }
}

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