org.apache.commons.math3.random.RandomDataGenerator.nextPermutation()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(4.3k)|赞(0)|评价(0)|浏览(157)

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

RandomDataGenerator.nextPermutation介绍

[英]This method calls MathArrays#shuffle(int[],RandomGenerator) in order to create a random shuffle of the set of natural numbers { 0, 1, ..., n - 1 }}.
[中]该方法调用MathArrays#shuffle(int[],RandomGenerator),以创建自然数集{0,1,…,n-1}的随机洗牌。

代码示例

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

/**
 * {@inheritDoc}
 *
 * <p>
 * Uses a 2-cycle permutation shuffle. The shuffling process is described <a
 * href="http://www.maths.abdn.ac.uk/~igc/tch/mx4002/notes/node83.html">
 * here</a>.
 * </p>
 */
public int[] nextPermutation(int n, int k)
  throws NotStrictlyPositiveException, NumberIsTooLargeException {
  return delegate.nextPermutation(n, k);
}

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

/**
 * {@inheritDoc}
 *
 * This method calls {@link #nextPermutation(int,int) nextPermutation(c.size(), k)}
 * in order to sample the collection.
 */
public Object[] nextSample(Collection<?> c, int k) throws NumberIsTooLargeException, NotStrictlyPositiveException {
  int len = c.size();
  if (k > len) {
    throw new NumberIsTooLargeException(LocalizedFormats.SAMPLE_SIZE_EXCEEDS_COLLECTION_SIZE,
                      k, len, true);
  }
  if (k <= 0) {
    throw new NotStrictlyPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES, k);
  }
  Object[] objects = c.toArray();
  int[] index = nextPermutation(len, k);
  Object[] result = new Object[k];
  for (int i = 0; i < k; i++) {
    result[i] = objects[index[i]];
  }
  return result;
}

代码示例来源:origin: OryxProject/oryx

int[] indices = rdg.nextPermutation(howManyCombos, howMany);
List<List<?>> result = new ArrayList<>(indices.length);
for (int i = 0; i < indices.length; i++) {

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

/**
 * {@inheritDoc}
 *
 * <p>
 * Uses a 2-cycle permutation shuffle. The shuffling process is described <a
 * href="http://www.maths.abdn.ac.uk/~igc/tch/mx4002/notes/node83.html">
 * here</a>.
 * </p>
 */
public int[] nextPermutation(int n, int k)
  throws NotStrictlyPositiveException, NumberIsTooLargeException {
  return delegate.nextPermutation(n, k);
}

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

/**
 * {@inheritDoc}
 *
 * <p>
 * Uses a 2-cycle permutation shuffle. The shuffling process is described <a
 * href="http://www.maths.abdn.ac.uk/~igc/tch/mx4002/notes/node83.html">
 * here</a>.
 * </p>
 */
public int[] nextPermutation(int n, int k)
  throws NotStrictlyPositiveException, NumberIsTooLargeException {
  return delegate.nextPermutation(n, k);
}

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

/**
 * {@inheritDoc}
 *
 * This method calls {@link #nextPermutation(int,int) nextPermutation(c.size(), k)}
 * in order to sample the collection.
 */
public Object[] nextSample(Collection<?> c, int k) throws NumberIsTooLargeException, NotStrictlyPositiveException {
  int len = c.size();
  if (k > len) {
    throw new NumberIsTooLargeException(LocalizedFormats.SAMPLE_SIZE_EXCEEDS_COLLECTION_SIZE,
                      k, len, true);
  }
  if (k <= 0) {
    throw new NotStrictlyPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES, k);
  }
  Object[] objects = c.toArray();
  int[] index = nextPermutation(len, k);
  Object[] result = new Object[k];
  for (int i = 0; i < k; i++) {
    result[i] = objects[index[i]];
  }
  return result;
}

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

/**
 * {@inheritDoc}
 *
 * This method calls {@link #nextPermutation(int,int) nextPermutation(c.size(), k)}
 * in order to sample the collection.
 */
public Object[] nextSample(Collection<?> c, int k) throws NumberIsTooLargeException, NotStrictlyPositiveException {
  int len = c.size();
  if (k > len) {
    throw new NumberIsTooLargeException(LocalizedFormats.SAMPLE_SIZE_EXCEEDS_COLLECTION_SIZE,
                      k, len, true);
  }
  if (k <= 0) {
    throw new NotStrictlyPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES, k);
  }
  Object[] objects = c.toArray();
  int[] index = nextPermutation(len, k);
  Object[] result = new Object[k];
  for (int i = 0; i < k; i++) {
    result[i] = objects[index[i]];
  }
  return result;
}

代码示例来源:origin: com.cloudera.oryx/oryx-ml

int[] indices = rdg.nextPermutation(howManyCombos, howMany);
List<List<?>> result = new ArrayList<>(indices.length);
for (int i = 0; i < indices.length; i++) {

代码示例来源:origin: org.opencb.hpg-bigdata/hpg-bigdata-analysis

int[] sample = random.nextPermutation(numIndividuals, numIndividuals);
for (int j = 0; j < sample.length; j++) {
  newPhenotype.setEntry(j, phenotype.getEntry(sample[j]));

相关文章

微信公众号

最新文章

更多