Example usage for org.apache.commons.math3.distribution ExponentialDistribution reseedRandomGenerator

List of usage examples for org.apache.commons.math3.distribution ExponentialDistribution reseedRandomGenerator

Introduction

In this page you can find the example usage for org.apache.commons.math3.distribution ExponentialDistribution reseedRandomGenerator.

Prototype

public void reseedRandomGenerator(long seed) 

Source Link

Usage

From source file:com.github.rinde.rinsim.scenario.measure.MetricsTest.java

static Times generateTimes(RandomGenerator rng, double intensity) {
    final ExponentialDistribution ed = new ExponentialDistribution(1000d / intensity);
    ed.reseedRandomGenerator(rng.nextLong());
    final List<Long> times = newArrayList();

    long sum = 0;
    while (sum < 1000) {
        sum += DoubleMath.roundToLong(ed.sample(), RoundingMode.HALF_DOWN);
        if (sum < 1000) {
            times.add(sum);//from   w w  w .j ava  2s  . c  o  m
        }
    }
    return asTimes(1000, times);
}