本文整理汇总了Java中org.apache.commons.math3.random.Well19937c类的典型用法代码示例。如果您正苦于以下问题:Java Well19937c类的具体用法?Java Well19937c怎么用?Java Well19937c使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Well19937c类属于org.apache.commons.math3.random包,在下文中一共展示了Well19937c类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateVMsRandom
import org.apache.commons.math3.random.Well19937c; //导入依赖的package包/类
public void generateVMsRandom(int totalVmNum) {
int vmCount = 0;
double lastStartTime = 0;
double startMean = 1800; // sec = 30min
double durScale=14400; // sec = 4 hours
double durShape=1.2;
Random rVmNum = new Random(seed);
ExponentialDistribution rStartTime = new ExponentialDistribution(new Well19937c(seed), startMean, ExponentialDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
ParetoDistribution rDuration = new ParetoDistribution(new Well19937c(seed), durScale, durShape);
while(vmCount < totalVmNum) {
int vmsInGroup = rVmNum.nextInt(4)+2;
double duration = Math.floor(rDuration.sample());
vmGenerator.generateVMGroup(vmsInGroup, lastStartTime, lastStartTime+duration, null);
lastStartTime += Math.floor(rStartTime.sample());
vmCount += vmsInGroup;
}
}
开发者ID:gmartinezramirez,项目名称:Fog-Computing-Mobile-Architecture,代码行数:24,代码来源:VMRequestRandomGenerator.java
示例2: generateVMs
import org.apache.commons.math3.random.Well19937c; //导入依赖的package包/类
public List<VMSpec> generateVMs(int totalVmNum) {
double lastStartTime = 0;
double startMean = 1800; // sec = 30min
double durScale=14400; // sec = 4 hours
double durShape=1.2;
Random rVmNum = new Random(seed);
ExponentialDistribution rStartTime = new ExponentialDistribution(new Well19937c(seed), startMean, ExponentialDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
ParetoDistribution rDuration = new ParetoDistribution(new Well19937c(seed), durScale, durShape);
List<VMSpec> vms = new ArrayList<VMSpec>();
while(this.vmId < totalVmNum) {
int vmsInGroup = rVmNum.nextInt(4)+2;
double duration = Math.floor(rDuration.sample());
vms.addAll(generateVMGroup(vmsInGroup, lastStartTime, lastStartTime+duration));
lastStartTime += Math.floor(rStartTime.sample());
}
return vms;
}
示例3: CMParameters
import org.apache.commons.math3.random.Well19937c; //导入依赖的package包/类
/**
* Constructs a new <code>CMParameters</code> configured from the given <code>MergeContext</code>.
*
* @param context
* the <code>MergeContext</code> to use
*/
public CMParameters(MergeContext context) {
setNoMatchWeight(context.getWn());
setRenamingWeight(context.getWr());
setAncestryViolationWeight(context.getWa());
setSiblingGroupBreakupWeight(context.getWs());
setOrderingWeight(context.getWo());
rng = new RandomAdaptor(context.getSeed().map(Well19937c::new).orElse(new Well19937c()));
assignDist = new PascalDistribution(rng, 1, context.getpAssign());
setPAssign(context.getpAssign());
setFixLower(context.getFixLower());
setFixUpper(context.getFixUpper());
setBeta(30);
setParallel(context.isCmMatcherParallel());
setFixRandomPercentage(context.isCmMatcherFixRandomPercentage());
lcaCache = new ConcurrentHashMap<>();
siblingCache = new ConcurrentHashMap<>();
otherSiblingsCache = new ConcurrentHashMap<>();
exactContainsCache = new ConcurrentHashMap<>();
boundContainsCache = new ConcurrentHashMap<>();
}
示例4: generateVMsRandom
import org.apache.commons.math3.random.Well19937c; //导入依赖的package包/类
public void generateVMsRandom(int totalVmNum) {
int vmCount = 0;
double lastStartTime = 0;
double startMean = 1800; // sec = 30min
double durScale=14400; // sec = 4 hours
double durShape=1.2;
Random rVmNum = new Random(seed);
ExponentialDistribution rStartTime = new ExponentialDistribution(new Well19937c(seed), startMean, ExponentialDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
ParetoDistribution rDuration = new ParetoDistribution(new Well19937c(seed), durScale, durShape);
int vmGroup=0;
while(vmCount < totalVmNum) {
int vmsInGroup = rVmNum.nextInt(4)+2;
double duration = Math.floor(rDuration.sample());
vmGenerator.generateVMGroup(vmsInGroup, lastStartTime, lastStartTime+duration, null, vmGroup, -1);
lastStartTime += Math.floor(rStartTime.sample());
vmCount += vmsInGroup;
vmGroup++;
}
}
示例5: canTestDoubleErrorRange
import org.apache.commons.math3.random.Well19937c; //导入依赖的package包/类
@Test
public void canTestDoubleErrorRange()
{
Assume.assumeTrue(true);
RandomGenerator r = new Well19937c(30051977);
TurboList<TestFastLog> test = new TurboList<TestFastLog>();
int n = 13;
test.add(new TestFastLog(ICSIFastLog.create(n, DataType.DOUBLE)));
test.add(new TestFastLog(new FFastLog(n)));
test.add(new TestFastLog(new DFastLog(n)));
test.add(new TestFastLog(new TurboLog(n)));
// Full range in blocks.
// Only when the number is around 1 or min value are there significant errors
double[] d = new double[10000000], logD = null;
// All
//testDoubleErrorRange(test, n, d, logD, 0, 255, 0);
// Only a problem around min value and x==1
//testDoubleErrorRange(r, test, n, d, logD, 0, 2, 0);
testDoubleErrorRange(r, test, n, d, logD, 1021, 1026, 0);
testDoubleErrorRange(r, test, n, d, logD, 2045, 2047, 0);
}
示例6: Worker
import org.apache.commons.math3.random.Well19937c; //导入依赖的package包/类
public Worker(BlockingQueue<Job> jobs, ImagePSFModel psf, int width, FitConfiguration fitConfig)
{
this.jobs = jobs;
this.psf = psf.copy();
this.fitConfig2 = fitConfig.clone();
sx = fitConfig.getInitialXSD();
sy = fitConfig.getInitialYSD();
a = psfSettings.getPixelSize() * scale;
xy = PSFDrift.getStartPoints(PSFDrift.this);
w = width;
w2 = w * w;
if (useSampling)
random = new RandomDataGenerator(new Well19937c());
else
random = null;
createBounds();
}
示例7: canTestDoubleSpeedLog1P
import org.apache.commons.math3.random.Well19937c; //导入依赖的package包/类
@Test
public void canTestDoubleSpeedLog1P()
{
RandomGenerator r = new Well19937c(30051977);
double[] x = new double[1000000];
for (int i = 0; i < x.length; i++)
{
x[i] = nextUniformDouble(r);
}
MathLog f = new MathLog();
TimingService ts = new TimingService(5);
//ts.execute(new DoubleTimingTask(new TestLog(f), 0, x));
ts.execute(new DoubleTimingTask(new Test1PLog(f), 0, x));
ts.execute(new DoubleTimingTask(new TestLog1P(f), 0, x));
ts.execute(new DoubleTimingTask(new TestLog1PApache(f), 0, x));
//ts.execute(new DoubleTimingTask(new TestLog(f), 0, x));
ts.execute(new DoubleTimingTask(new Test1PLog(f), 0, x));
ts.execute(new DoubleTimingTask(new TestLog1P(f), 0, x));
ts.execute(new DoubleTimingTask(new TestLog1PApache(f), 0, x));
int size = ts.getSize();
ts.repeat(size);
ts.report(size);
}
示例8: canProduceSubset
import org.apache.commons.math3.random.Well19937c; //导入依赖的package包/类
@Test
public void canProduceSubset()
{
int k = 5;
int n = 10;
RandomGenerator randomGenerator = new Well19937c(30051977);
FisherInformationMatrix m = createRandomMatrix(randomGenerator, n);
DenseMatrix64F e = m.getMatrix();
System.out.println(e);
for (int run = 1; run < 10; run++)
{
int[] indices = Random.sample(k, n, randomGenerator);
Arrays.sort(indices);
DenseMatrix64F o = m.subset(indices).getMatrix();
System.out.println(Arrays.toString(indices));
System.out.println(o);
for (int i = 0; i < indices.length; i++)
for (int j = 0; j < indices.length; j++)
{
Assert.assertEquals(e.get(indices[i], indices[j]), o.get(i, j), 0);
}
}
}
示例9: createCMAESOptimizer
import org.apache.commons.math3.random.Well19937c; //导入依赖的package包/类
private CMAESOptimizer createCMAESOptimizer()
{
double rel = 1e-8;
double abs = 1e-10;
int maxIterations = 2000;
double stopFitness = 0; //Double.NEGATIVE_INFINITY;
boolean isActiveCMA = true;
int diagonalOnly = 20;
int checkFeasableCount = 1;
RandomGenerator random = new Well19937c();
boolean generateStatistics = false;
ConvergenceChecker<PointValuePair> checker = new SimpleValueChecker(rel, abs);
// Iterate this for stability in the initial guess
return new CMAESOptimizer(maxIterations, stopFitness, isActiveCMA, diagonalOnly, checkFeasableCount, random,
generateStatistics, checker);
}
示例10: gradientProcedureComputesSameAsGradientCalculator
import org.apache.commons.math3.random.Well19937c; //导入依赖的package包/类
private void gradientProcedureComputesSameAsGradientCalculator(int nparams)
{
int iter = 10;
rdg = new RandomDataGenerator(new Well19937c(30051977));
ArrayList<double[]> paramsList = new ArrayList<double[]>(iter);
createFakeParams(nparams, iter, paramsList);
int n = blockWidth * blockWidth;
FakeGradientFunction func = new FakeGradientFunction(blockWidth, nparams);
GradientCalculator calc = GradientCalculatorFactory.newCalculator(nparams, false);
String name = String.format("[%d]", nparams);
for (int i = 0; i < paramsList.size(); i++)
{
LSQVarianceGradientProcedure p = LSQVarianceGradientProcedureFactory.create(func);
p.variance(paramsList.get(i));
double[] e = calc.variance(n, paramsList.get(i), func);
Assert.assertArrayEquals(name + " Observations: Not same @ " + i, e, p.variance, 0);
}
}
示例11: getRandom
import org.apache.commons.math3.random.Well19937c; //导入依赖的package包/类
/**
* @return a new, seeded {@link RandomGenerator}
*/
public static RandomGenerator getRandom() {
if (useTestSeed) {
// No need to track instances anymore
return new Well19937c(TEST_SEED);
}
return getUnseededRandom();
}
示例12: getUnseededRandom
import org.apache.commons.math3.random.Well19937c; //导入依赖的package包/类
static RandomGenerator getUnseededRandom() {
RandomGenerator random = new Well19937c();
Collection<RandomGenerator> instances = INSTANCES.get();
if (instances != null) {
synchronized (instances) {
instances.add(random);
}
} // else oh well, only matters in tests
return random;
}
示例13: test
import org.apache.commons.math3.random.Well19937c; //导入依赖的package包/类
@Test
public void test() {
final Well19937c rnd = new Well19937c(0);
final double[] data = Vectors.append(new NormalDistribution(rnd, 10, 5).sample(50),
new NormalDistribution(rnd, 4000, 100).sample(75));
final Point[] points = new Point[data.length];
for (int i = 0; i < points.length; ++i) {
points[i] = new Point(data[i]);
}
final Components result = Components.of(new GaussianMixtureModels().run(points, 2, 10));
System.err.println(result);
Assert.assertEquals(-685.3993, result.incompleteLogLikelihood(data), 0.0001);
Assert.assertEquals(-690.2276, result.bic(data), 0.0001);
}
示例14: createRandomIterator
import org.apache.commons.math3.random.Well19937c; //导入依赖的package包/类
/**
* Creates an iterator that will present a series of points coordinates in
* a random order.
*
* @param numSamples Number of samples.
* @return the iterator.
*/
private Iterator<double[]> createRandomIterator(final long numSamples) {
return new Iterator<double[]>() {
/** Data. */
final Vector3D[] points = rings.getPoints();
/** RNG. */
final RandomGenerator rng = new Well19937c();
/** Number of samples. */
private long n = 0;
/** {@inheritDoc} */
public boolean hasNext() {
return n < numSamples;
}
/** {@inheritDoc} */
public double[] next() {
++n;
return points[rng.nextInt(points.length)].toArray();
}
/** {@inheritDoc} */
public void remove() {
throw new MathUnsupportedOperationException();
}
};
}
示例15: VoltMeter
import org.apache.commons.math3.random.Well19937c; //导入依赖的package包/类
public VoltMeter(double voltage, double processNoise, double measurementNoise, int seed) {
this.initialVoltage = voltage;
this.voltage = voltage;
this.processNoise = processNoise;
this.measurementNoise = measurementNoise;
rng = new Well19937c(seed);
}