本文整理了Java中org.apache.commons.math3.random.RandomDataGenerator.nextSample
方法的一些代码示例,展示了RandomDataGenerator.nextSample
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RandomDataGenerator.nextSample
方法的具体详情如下:
包路径:org.apache.commons.math3.random.RandomDataGenerator
类名称:RandomDataGenerator
方法名:nextSample
[英]This method calls #nextPermutation(int,int)in order to sample the collection.
[中]此方法调用#nextpermutate(int,int)以对集合进行采样。
代码示例来源:origin: org.apache.commons/commons-math3
/**
* {@inheritDoc}
*
* <p>
* <strong>Algorithm Description</strong>: Uses a 2-cycle permutation
* shuffle to generate a random permutation of <code>c.size()</code> and
* then returns the elements whose indexes correspond to the elements of the
* generated permutation. This technique is described, and proven to
* generate random samples <a
* href="http://www.maths.abdn.ac.uk/~igc/tch/mx4002/notes/node83.html">
* here</a>
* </p>
*/
public Object[] nextSample(Collection<?> c, int k)
throws NotStrictlyPositiveException, NumberIsTooLargeException {
return delegate.nextSample(c, k);
}
代码示例来源:origin: io.virtdata/virtdata-lib-realer
/**
* {@inheritDoc}
*
* <p>
* <strong>Algorithm Description</strong>: Uses a 2-cycle permutation
* shuffle to generate a random permutation of <code>c.size()</code> and
* then returns the elements whose indexes correspond to the elements of the
* generated permutation. This technique is described, and proven to
* generate random samples <a
* href="http://www.maths.abdn.ac.uk/~igc/tch/mx4002/notes/node83.html">
* here</a>
* </p>
*/
public Object[] nextSample(Collection<?> c, int k)
throws NotStrictlyPositiveException, NumberIsTooLargeException {
return delegate.nextSample(c, k);
}
代码示例来源:origin: geogebra/geogebra
/**
* {@inheritDoc}
*
* <p>
* <strong>Algorithm Description</strong>: Uses a 2-cycle permutation
* shuffle to generate a random permutation of <code>c.size()</code> and
* then returns the elements whose indexes correspond to the elements of the
* generated permutation. This technique is described, and proven to
* generate random samples <a
* href="http://www.maths.abdn.ac.uk/~igc/tch/mx4002/notes/node83.html">
* here</a>
* </p>
*/
public Object[] nextSample(Collection<?> c, int k)
throws NotStrictlyPositiveException, NumberIsTooLargeException {
return delegate.nextSample(c, k);
}
代码示例来源:origin: org.apache.accumulo/accumulo-test
private void changeTableSetting(RandomDataGenerator random, State state, Environment env,
Properties props) throws Exception {
// pick a random property
int choice = random.nextInt(0, tableSettings.length - 1);
Setting setting = tableSettings[choice];
// pick a random table
SortedSet<String> tables = env.getConnector().tableOperations().list().tailSet("ctt")
.headSet("ctu");
if (tables.isEmpty())
return;
String table = random.nextSample(tables, 1)[0].toString();
// generate a random value
long newValue = random.nextLong(setting.min, setting.max);
state.set(LAST_TABLE_SETTING, table + "," + choice);
log.debug("Setting " + setting.property.getKey() + " on table " + table + " to " + newValue);
try {
env.getConnector().tableOperations().setProperty(table, setting.property.getKey(),
"" + newValue);
} catch (AccumuloException ex) {
if (ex.getCause() instanceof ThriftTableOperationException) {
ThriftTableOperationException ttoe = (ThriftTableOperationException) ex.getCause();
if (ttoe.type == TableOperationExceptionType.NOTFOUND)
return;
}
throw ex;
}
}
代码示例来源:origin: org.apache.accumulo/accumulo-test
private void changeNamespaceSetting(RandomDataGenerator random, State state, Environment env,
Properties props) throws Exception {
// pick a random property
int choice = random.nextInt(0, tableSettings.length - 1);
Setting setting = tableSettings[choice];
// pick a random table
SortedSet<String> namespaces = env.getConnector().namespaceOperations().list().tailSet("nspc")
.headSet("nspd");
if (namespaces.isEmpty())
return;
String namespace = random.nextSample(namespaces, 1)[0].toString();
// generate a random value
long newValue = random.nextLong(setting.min, setting.max);
state.set(LAST_NAMESPACE_SETTING, namespace + "," + choice);
log.debug(
"Setting " + setting.property.getKey() + " on namespace " + namespace + " to " + newValue);
try {
env.getConnector().namespaceOperations().setProperty(namespace, setting.property.getKey(),
"" + newValue);
} catch (AccumuloException ex) {
if (ex.getCause() instanceof ThriftTableOperationException) {
ThriftTableOperationException ttoe = (ThriftTableOperationException) ex.getCause();
if (ttoe.type == TableOperationExceptionType.NAMESPACE_NOTFOUND)
return;
}
throw ex;
}
}
内容来源于网络,如有侵权,请联系作者删除!