當前位置: 首頁>>代碼示例>>Java>>正文


Java RandomDataGenerator.nextInt方法代碼示例

本文整理匯總了Java中org.apache.commons.math3.random.RandomDataGenerator.nextInt方法的典型用法代碼示例。如果您正苦於以下問題:Java RandomDataGenerator.nextInt方法的具體用法?Java RandomDataGenerator.nextInt怎麽用?Java RandomDataGenerator.nextInt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.math3.random.RandomDataGenerator的用法示例。


在下文中一共展示了RandomDataGenerator.nextInt方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createSpots

import org.apache.commons.math3.random.RandomDataGenerator; //導入方法依賴的package包/類
private static float[] createSpots(int size, int n, int min, int max, double sigmaX, double sigmaY)
{
	float[] data = new float[size * size];
	// Randomly put on spots
	RandomDataGenerator rg = new RandomDataGenerator(rand);
	while (n-- > 0)
	{
		data[rand.nextInt(data.length)] = rg.nextInt(min, max);
	}

	// Blur
	FloatProcessor fp = new FloatProcessor(size, size, data);
	GaussianBlur gb = new GaussianBlur();
	gb.blurFloat(fp, sigmaX, sigmaY, 0.0002);

	return (float[]) fp.getPixels();
}
 
開發者ID:aherbert,項目名稱:GDSC,代碼行數:18,代碼來源:FindFociTest.java

示例2: createSpots3D

import org.apache.commons.math3.random.RandomDataGenerator; //導入方法依賴的package包/類
private static float[][] createSpots3D(int size, int z, int n, int min, int max, double sigmaX, double sigmaY)
{
	float[] data = new float[size * size];
	// Randomly put on spots
	RandomDataGenerator rg = new RandomDataGenerator(rand);
	while (n-- > 0)
	{
		data[rand.nextInt(data.length)] = rg.nextInt(min, max);
	}

	int middle = z / 2;
	float[][] result = new float[z][];
	for (int i = 0; i < z; i++)
	{
		FloatProcessor fp = new FloatProcessor(size, size, data.clone());
		GaussianBlur gb = new GaussianBlur();
		// Increase blur when out-of-focus
		double scale = createWidthScale(Math.abs(middle - i), middle);
		gb.blurFloat(fp, sigmaX * scale, sigmaY * scale, 0.0002);
		result[i] = (float[]) fp.getPixels();
	}
	return result;
}
 
開發者ID:aherbert,項目名稱:GDSC,代碼行數:24,代碼來源:FindFociTest.java

示例3: getRandomValue

import org.apache.commons.math3.random.RandomDataGenerator; //導入方法依賴的package包/類
/**
 * @param rdg random number generator to use
 * @return a hyperparameter value chosen uniformly at random from the range
 */
@Override
public Integer getRandomValue(RandomDataGenerator rdg) {
  if (max == min) {
    return min;
  }
  return rdg.nextInt(min, max);
}
 
開發者ID:oncewang,項目名稱:oryx2,代碼行數:12,代碼來源:DiscreteRange.java

示例4: moveCellsWithOffset

import org.apache.commons.math3.random.RandomDataGenerator; //導入方法依賴的package包/類
public void moveCellsWithOffset(Array<? extends Rectangle> cells, int x, int y, int offsetX, int offsetY) {
    Gdx.app.log("RectanglesSeparator", "Moving cells to (" + x + ", " + y + ")");

    RandomDataGenerator randomDataGenerator = new RandomDataGenerator();

    for (Rectangle cell : cells) {
        if (!(cell instanceof GameRoom)) {
            // X/Y +- 1 so they are not stacked at the exact same spot and can't separate
            int newX = randomDataGenerator.nextInt(x - offsetX, x + offsetX);
            int newY = randomDataGenerator.nextInt(y - offsetY, y + offsetY);
            cell.setCenter(new Vector2(newX, newY));
        }
    }
}
 
開發者ID:LeonardBesson,項目名稱:DunGen,代碼行數:15,代碼來源:OverlappingRectanglesSeparator.java

示例5: getRandomInt

import org.apache.commons.math3.random.RandomDataGenerator; //導入方法依賴的package包/類
private int getRandomInt(int lower, int upper) {
    RandomDataGenerator randomDataGenerator = new RandomDataGenerator();

    if (upper < lower) {
        upper = lower;
    }

    return randomDataGenerator.nextInt(lower, upper);
}
 
開發者ID:LeonardBesson,項目名稱:DunGen,代碼行數:10,代碼來源:CorridorGenerator.java

示例6: generate

import org.apache.commons.math3.random.RandomDataGenerator; //導入方法依賴的package包/類
public void generate(int sleep_frequency) throws InterruptedException {

        RandomDataGenerator messageGenerator = new RandomDataGenerator();
        long time = System.currentTimeMillis();

        ThroughputLog throughput = new ThroughputLog(this.getClass().getSimpleName());
        // for loop to generate message
        for (long sent_sentences = 0; sent_sentences < SENTENCE_NUM; ++sent_sentences) {
            double sentence_length = messageGenerator.nextGaussian(mu, sigma);
            StringBuilder messageBuilder = new StringBuilder();
            for (int l = 0; l < sentence_length; ++l) {
                int number = messageGenerator.nextInt(1, uniformSize);
                messageBuilder.append(Utils.intToString(number)).append(" ");
            }

            // Add timestamp
            messageBuilder.append(Constant.TimeSeparator).append(System.currentTimeMillis());
            throughput.execute();
            ProducerRecord<String, String> newRecord = new ProducerRecord<>(TOPIC, messageBuilder.toString());
            producer.send(newRecord);

            // control data generate speed
            if (sleep_frequency > 0 && sent_sentences % sleep_frequency == 0) {
                Thread.sleep(1);
            }
        }
        producer.close();
        logger.info("LatencyLog: " + String.valueOf(System.currentTimeMillis() - time));
    }
 
開發者ID:wangyangjun,項目名稱:StreamBench,代碼行數:30,代碼來源:UniformWordCount.java

示例7: initRows

import org.apache.commons.math3.random.RandomDataGenerator; //導入方法依賴的package包/類
private void initRows() {
    rows.clear();
    final RandomDataGenerator rng = new RandomDataGenerator();
    final List<Pupil> pupils = new ArrayList<Pupil>(Arrays.asList(Pupil.values()));
    while (!pupils.isEmpty()) {
        final int index;
        if (pupils.size() > 1) {
            index = rng.nextInt(0, pupils.size() - 1);
        } else {
            index = 0;
        }
        final Pupil pupil = pupils.remove(index);
        rows.add(new DashboardRow(pupil));
    }
}
 
開發者ID:subes,項目名稱:invesdwin-nowicket,代碼行數:16,代碼來源:Dashboard.java

示例8: nextUnlabeled

import org.apache.commons.math3.random.RandomDataGenerator; //導入方法依賴的package包/類
private int nextUnlabeled(  ){
	RandomDataGenerator rand = new RandomDataGenerator();
	int start = rand.nextInt(0, edgels.size()-1);
	for ( int i=start; i<edgels.size(); i++){
		if( labelMems[i] == 0 ) return i;
	}
	return -1;
}
 
開發者ID:bogovicj,項目名稱:hhmi-exp,代碼行數:9,代碼來源:EdgelClusteringRansac.java

示例9: uniform

import org.apache.commons.math3.random.RandomDataGenerator; //導入方法依賴的package包/類
@Override
public Integer uniform( RandomDataGenerator random, Integer min, Integer max )
{
    if ( min == max )
    {
        return min;
    }
    return random.nextInt( min, max );
}
 
開發者ID:ldbc,項目名稱:ldbc_snb_driver,代碼行數:10,代碼來源:NumberHelper.java

示例10: nextInt

import org.apache.commons.math3.random.RandomDataGenerator; //導入方法依賴的package包/類
/** Same as random.nextInt(lower, upper), but does not throw exception when lower == upper */
public static int nextInt(int lower, int upper, RandomDataGenerator random) {
	return lower == upper ? lower : random.nextInt(lower, upper);
}
 
開發者ID:wjaskowski,項目名稱:2048-gecco-2015-competition,代碼行數:5,代碼來源:RandomUtils.java

示例11: jTransforms2DDHTIsFasterThanFHT2

import org.apache.commons.math3.random.RandomDataGenerator; //導入方法依賴的package包/類
@Test
public void jTransforms2DDHTIsFasterThanFHT2()
{
	// Test the forward DHT of data. and reverse transform or the pre-computed correlation.

	int size = 256;
	int w = size / 4;
	RandomGenerator r = new Well19937c(30051977);
	RandomDataGenerator rdg = new RandomDataGenerator(r);

	// Blob in the centre
	FloatProcessor fp = createProcessor(size, size / 2 - w / 2, size / 2 - w / 2, w, w, null);
	FHT2 fht2 = new FHT2((float[]) fp.getPixels(), size, false);
	fht2.transform();
	fht2.initialiseFastMultiply();

	// Random blobs, original and correlated
	int N = 40;
	float[][] data = new float[N * 2][];
	int lower = w;
	int upper = size - w;
	for (int i = 0, j = 0; i < N; i++)
	{
		int x = rdg.nextInt(lower, upper);
		int y = rdg.nextInt(lower, upper);
		fp = createProcessor(size, x, y, w, w, r);
		float[] pixels = (float[]) fp.getPixels();
		data[j++] = pixels.clone();
		FHT2 fht1 = new FHT2(pixels, size, false);
		fht1.copyTables(fht2);
		fht2.transform();
		float[] pixels2 = new float[pixels.length];
		fht2.conjugateMultiply(fht2, pixels2);
		data[j++] = pixels2;
	}

	//CommonUtils.setThreadsBeginN_1D_FFT_2Threads(Long.MAX_VALUE);
	//CommonUtils.setThreadsBeginN_1D_FFT_4Threads(Long.MAX_VALUE);
	CommonUtils.setThreadsBeginN_2D(Long.MAX_VALUE);

	TimingService ts = new TimingService();
	ts.execute(new IJFHTSpeedTask(size, data));
	ts.execute(new IJFHT2SpeedTask(size, data));
	ts.execute(new JTransformsDHTSpeedTask(size, data));
	ts.repeat();
	ts.report();

	Assert.assertTrue(ts.get(-1).getMean() < ts.get(-2).getMean());
}
 
開發者ID:aherbert,項目名稱:GDSC-SMLM,代碼行數:50,代碼來源:JTransformsTest.java


注:本文中的org.apache.commons.math3.random.RandomDataGenerator.nextInt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。