本文整理汇总了Java中com.pholser.junit.quickcheck.random.SourceOfRandomness.nextInt方法的典型用法代码示例。如果您正苦于以下问题:Java SourceOfRandomness.nextInt方法的具体用法?Java SourceOfRandomness.nextInt怎么用?Java SourceOfRandomness.nextInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.pholser.junit.quickcheck.random.SourceOfRandomness
的用法示例。
在下文中一共展示了SourceOfRandomness.nextInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generate
import com.pholser.junit.quickcheck.random.SourceOfRandomness; //导入方法依赖的package包/类
@Override
public Operation generate(SourceOfRandomness sourceOfRandomness, GenerationStatus generationStatus) {
switch (sourceOfRandomness.nextInt(18)) {
case 0: return new Put(randomKey(sourceOfRandomness), sourceOfRandomness.nextInt());
case 1: return new Get(randomKey(sourceOfRandomness));
case 2: return new LowerEntry(randomKey(sourceOfRandomness));
case 3: return new FloorEntry(randomKey(sourceOfRandomness));
case 4: return new HigherEntry(randomKey(sourceOfRandomness));
case 5: return new CeilingEntry(randomKey(sourceOfRandomness));
case 6: return new Size();
case 7: return new FirstEntry();
case 8: return new LastEntry();
case 9: return new Values();
case 10: return new DescendingValues();
case 11: return new TailMap(randomKey(sourceOfRandomness));
case 12: return new TailMapExclusive(randomKey(sourceOfRandomness));
case 13: return new HeadMap(randomKey(sourceOfRandomness));
case 14: return new HeadMapExclusive(randomKey(sourceOfRandomness));
case 15: return new DescendingTailMap(randomKey(sourceOfRandomness));
case 16: return new DescendingTailMapExclusive(randomKey(sourceOfRandomness));
case 17: return new Remove(randomKey(sourceOfRandomness));
default: throw new IllegalStateException();
}
}
示例2: generate
import com.pholser.junit.quickcheck.random.SourceOfRandomness; //导入方法依赖的package包/类
@Override
public ConcatVector generate(SourceOfRandomness sourceOfRandomness, GenerationStatus generationStatus) {
ConcatVector v = new ConcatVector(CONCAT_VEC_COMPONENTS);
for (int x = 0; x < CONCAT_VEC_COMPONENTS; x++) {
if (sourceOfRandomness.nextBoolean()) {
v.setSparseComponent(x, sourceOfRandomness.nextInt(CONCAT_VEC_COMPONENT_LENGTH), sourceOfRandomness.nextDouble());
}
else {
double[] val = new double[sourceOfRandomness.nextInt(CONCAT_VEC_COMPONENT_LENGTH)];
for (int y = 0; y < val.length; y++) {
val[y] = sourceOfRandomness.nextDouble();
}
v.setDenseComponent(x, val);
}
}
return v;
}
示例3: generate
import com.pholser.junit.quickcheck.random.SourceOfRandomness; //导入方法依赖的package包/类
@Override
public GraphicalModel generate(SourceOfRandomness sourceOfRandomness, GenerationStatus generationStatus) {
GraphicalModel model = new GraphicalModel();
// Create the variables and factors. These are deliberately tiny so that the brute force approach is tractable
int[] variableSizes = new int[sourceOfRandomness.nextInt(10, 50)];
for (int i = 0; i < variableSizes.length; i++) {
variableSizes[i] = sourceOfRandomness.nextInt(1, 8);
}
model.getModelMetaDataByReference().put(MTurkHumanSource.QUERY_JSON, "{}");
for (int i = 0; i < variableSizes.length; i++) {
model.getVariableMetaDataByReference(i).put(MTurkHumanSource.QUERY_JSON, "{}");
}
return model;
}
示例4: generate
import com.pholser.junit.quickcheck.random.SourceOfRandomness; //导入方法依赖的package包/类
@Override
public ConcatVector generate(SourceOfRandomness sourceOfRandomness, GenerationStatus generationStatus) {
ConcatVector v = new ConcatVector(CONCAT_VEC_COMPONENTS);
for (int x = 0; x < CONCAT_VEC_COMPONENTS; x++) {
if (sourceOfRandomness.nextBoolean()) {
v.setSparseComponent(x, sourceOfRandomness.nextInt(CONCAT_VEC_COMPONENT_LENGTH), sourceOfRandomness.nextDouble());
} else {
double[] val = new double[sourceOfRandomness.nextInt(CONCAT_VEC_COMPONENT_LENGTH)];
for (int y = 0; y < val.length; y++) {
val[y] = 2.0 * (sourceOfRandomness.nextDouble() - 0.5);
}
v.setDenseComponent(x, val);
}
}
return v;
}
示例5: generate
import com.pholser.junit.quickcheck.random.SourceOfRandomness; //导入方法依赖的package包/类
@Override
public ConcatVector generate(SourceOfRandomness sourceOfRandomness, GenerationStatus generationStatus) {
ConcatVector v = new ConcatVector(CONCAT_VEC_COMPONENTS);
for (int x = 0; x < CONCAT_VEC_COMPONENTS; x++) {
if (sourceOfRandomness.nextBoolean()) {
v.setSparseComponent(x, sourceOfRandomness.nextInt(CONCAT_VEC_COMPONENT_LENGTH), sourceOfRandomness.nextDouble());
} else {
double[] val = new double[sourceOfRandomness.nextInt(CONCAT_VEC_COMPONENT_LENGTH)];
for (int y = 0; y < val.length; y++) {
val[y] = sourceOfRandomness.nextDouble();
}
v.setDenseComponent(x, val);
}
}
return v;
}
示例6: generate
import com.pholser.junit.quickcheck.random.SourceOfRandomness; //导入方法依赖的package包/类
@Override
public Person generate(final SourceOfRandomness random, final GenerationStatus status)
{
return new Person(
random.nextBoolean() ? Gender.Male : Gender.Female,
random.nextInt(1, 130));
}
示例7: generateMetaData
import com.pholser.junit.quickcheck.random.SourceOfRandomness; //导入方法依赖的package包/类
private Map<String,String> generateMetaData(SourceOfRandomness sourceOfRandomness, Map<String,String> metaData) {
int numPairs = sourceOfRandomness.nextInt(9);
for (int i = 0; i < numPairs; i++) {
int key = sourceOfRandomness.nextInt();
int value = sourceOfRandomness.nextInt();
metaData.put("key:"+key, "value:"+value);
}
return metaData;
}
示例8: generateMetaData
import com.pholser.junit.quickcheck.random.SourceOfRandomness; //导入方法依赖的package包/类
private Map<String, String> generateMetaData(SourceOfRandomness sourceOfRandomness, Map<String, String> metaData) {
int numPairs = sourceOfRandomness.nextInt(9);
for (int i = 0; i < numPairs; i++) {
int key = sourceOfRandomness.nextInt();
int value = sourceOfRandomness.nextInt();
metaData.put("key:" + key, "value:" + value);
}
return metaData;
}
示例9: generate
import com.pholser.junit.quickcheck.random.SourceOfRandomness; //导入方法依赖的package包/类
@Override
public GraphicalModel[] generate(SourceOfRandomness sourceOfRandomness, GenerationStatus generationStatus) {
int datasetSize = sourceOfRandomness.nextInt(1,40);
GraphicalModel[] dataset = new GraphicalModel[datasetSize];
for (int i = 0; i < dataset.length; i++) {
dataset[i] = generator.generate(sourceOfRandomness, generationStatus);
}
return dataset;
}
示例10: generate
import com.pholser.junit.quickcheck.random.SourceOfRandomness; //导入方法依赖的package包/类
@Override
public ConcatVector[][][] generate(SourceOfRandomness sourceOfRandomness, GenerationStatus generationStatus) {
int l = sourceOfRandomness.nextInt(10) + 1;
int m = sourceOfRandomness.nextInt(10) + 1;
int n = sourceOfRandomness.nextInt(10) + 1;
ConcatVector[][][] factor3 = new ConcatVector[l][m][n];
for (int i = 0; i < factor3.length; i++) {
for (int j = 0; j < factor3[0].length; j++) {
for (int k = 0; k < factor3[0][0].length; k++) {
int numComponents = sourceOfRandomness.nextInt(7);
ConcatVector v = new ConcatVector(numComponents);
for (int x = 0; x < numComponents; x++) {
if (sourceOfRandomness.nextBoolean()) {
v.setSparseComponent(x, sourceOfRandomness.nextInt(32), sourceOfRandomness.nextDouble());
}
else {
double[] val = new double[sourceOfRandomness.nextInt(12)];
for (int y = 0; y < val.length; y++) {
val[y] = sourceOfRandomness.nextDouble();
}
v.setDenseComponent(x, val);
}
}
factor3[i][j][k] = v;
}
}
}
return factor3;
}
示例11: generateMetaData
import com.pholser.junit.quickcheck.random.SourceOfRandomness; //导入方法依赖的package包/类
private Map<String, String> generateMetaData(SourceOfRandomness sourceOfRandomness, Map<String, String> metaData) {
int numPairs = sourceOfRandomness.nextInt(9);
for (int i = 0; i < numPairs; i++) {
int key = sourceOfRandomness.nextInt();
int value = sourceOfRandomness.nextInt();
metaData.put("key:" + key, "value:" + value);
}
return metaData;
}
示例12: generate
import com.pholser.junit.quickcheck.random.SourceOfRandomness; //导入方法依赖的package包/类
@Override
public TableFactor generate(SourceOfRandomness sourceOfRandomness, GenerationStatus generationStatus) {
int numNeighbors = sourceOfRandomness.nextInt(1, 3);
int[] neighbors = new int[numNeighbors];
int[] dimensions = new int[numNeighbors];
Set<Integer> usedNeighbors = new HashSet<>();
for (int i = 0; i < neighbors.length; i++) {
while (true) {
int neighbor = sourceOfRandomness.nextInt(0, 3);
if (!usedNeighbors.contains(neighbor)) {
usedNeighbors.add(neighbor);
neighbors[i] = neighbor;
dimensions[i] = variableSizes[neighbor];
break;
}
}
}
// Make sure we get some all-0 factor tables
double multiple = sourceOfRandomness.nextDouble();
TableFactor factor = new TableFactor(neighbors, dimensions);
for (int[] assignment : factor) {
factor.setAssignmentValue(assignment, multiple * sourceOfRandomness.nextDouble());
}
return factor;
}
示例13: generate
import com.pholser.junit.quickcheck.random.SourceOfRandomness; //导入方法依赖的package包/类
@Override
public ModelBatch generate(SourceOfRandomness sourceOfRandomness, GenerationStatus generationStatus) {
int length = sourceOfRandomness.nextInt(0, 50);
ModelBatch batch = new ModelBatch();
for (int i = 0; i < length; i++) {
batch.add(modelGenerator.generate(sourceOfRandomness, generationStatus));
}
return batch;
}
示例14: generate
import com.pholser.junit.quickcheck.random.SourceOfRandomness; //导入方法依赖的package包/类
@Override
public Map<Integer, Integer> generate(SourceOfRandomness sourceOfRandomness, GenerationStatus generationStatus) {
int numFeatures = sourceOfRandomness.nextInt(1,15);
Map<Integer, Integer> featureMap = new HashMap<>();
for (int i = 0; i < numFeatures; i++) {
int featureValue = sourceOfRandomness.nextInt(20);
while (featureMap.containsKey(featureValue)) {
featureValue = sourceOfRandomness.nextInt(20);
}
featureMap.put(featureValue, sourceOfRandomness.nextInt(2));
}
return featureMap;
}
示例15: generateFeatureMap
import com.pholser.junit.quickcheck.random.SourceOfRandomness; //导入方法依赖的package包/类
private ObjectIntMap<String> generateFeatureMap(SourceOfRandomness sourceOfRandomness) {
ObjectIntMap<String> featureMap = new ObjectIntHashMap<>();
int numFeatures = sourceOfRandomness.nextInt(1,15);
for (int i = 0; i < numFeatures; i++) {
int featureValue = sourceOfRandomness.nextInt(20);
while (featureMap.containsKey(""+featureValue)) {
featureValue = sourceOfRandomness.nextInt(20);
}
featureMap.put(""+featureValue, sourceOfRandomness.nextInt(2));
}
return featureMap;
}