本文整理汇总了Java中org.apache.commons.math3.random.Well19937c类的典型用法代码示例。如果您正苦于以下问题:Java Well19937c类的具体用法?Java Well19937c怎么用?Java Well19937c使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Well19937c类属于org.apache.commons.math3.random包,在下文中一共展示了Well19937c类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:gmartinezramirez,项目名称:Fog-Computing-Mobile-Architecture,代码行数:24,代码来源:VMRequestGenerator.java
示例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<>();
}
开发者ID:se-passau,项目名称:jdime,代码行数:27,代码来源:CMParameters.java
示例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++;
}
}
开发者ID:jayjmin,项目名称:cloudsimsdn,代码行数:25,代码来源:VMRequestRandomGenerator.java
示例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);
}
开发者ID:aherbert,项目名称:GDSC-SMLM,代码行数:27,代码来源:FastLogTest.java
示例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();
}
开发者ID:aherbert,项目名称:GDSC-SMLM,代码行数:19,代码来源:PSFDrift.java
示例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);
}
开发者ID:aherbert,项目名称:GDSC-SMLM,代码行数:27,代码来源:FastLogTest.java
示例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);
}
}
}
开发者ID:aherbert,项目名称:GDSC-SMLM,代码行数:26,代码来源:FisherInformationMatrixTest.java
示例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);
}
开发者ID:aherbert,项目名称:GDSC-SMLM,代码行数:18,代码来源:JumpDistanceAnalysis.java
示例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);
}
}
开发者ID:aherbert,项目名称:GDSC-SMLM,代码行数:24,代码来源:LSQVarianceGradientProcedureTest.java
示例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();
}
开发者ID:oncewang,项目名称:oryx2,代码行数:11,代码来源:RandomManager.java
示例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;
}
开发者ID:oncewang,项目名称:oryx2,代码行数:11,代码来源:RandomManager.java
示例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);
}
开发者ID:ProfilingIO,项目名称:insight-ml,代码行数:15,代码来源:GaussianMixtureModelsTest.java
示例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();
}
};
}
开发者ID:Quanticol,项目名称:CARMA,代码行数:34,代码来源:ChineseRingsClassifier.java
示例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);
}
开发者ID:Quanticol,项目名称:CARMA,代码行数:8,代码来源:ConstantVoltageExample.java
示例16: Cannonball
import org.apache.commons.math3.random.Well19937c; //导入依赖的package包/类
public Cannonball(double timeslice, double angle, double initialVelocity, double measurementNoise, int seed) {
this.timeslice = timeslice;
final double angleInRadians = FastMath.toRadians(angle);
this.velocity = new double[] {
initialVelocity * FastMath.cos(angleInRadians),
initialVelocity * FastMath.sin(angleInRadians)
};
this.location = new double[] { 0, 0 };
this.measurementNoise = measurementNoise;
this.rng = new Well19937c(seed);
}
开发者ID:Quanticol,项目名称:CARMA,代码行数:15,代码来源:CannonballExample.java
示例17: testTwoSampleMonteCarlo
import org.apache.commons.math3.random.Well19937c; //导入依赖的package包/类
/**
* Verifies that Monte Carlo simulation gives results close to exact p values. This test is a
* little long-running (more than two minutes on a fast machine), so is disabled by default.
*/
// @Test
public void testTwoSampleMonteCarlo() {
final KolmogorovSmirnovTest test = new KolmogorovSmirnovTest(new Well19937c(1000));
final int sampleSize = 14;
final double tol = .001;
final double[] shortUniform = new double[sampleSize];
System.arraycopy(uniform, 0, shortUniform, 0, sampleSize);
final double[] shortGaussian = new double[sampleSize];
final double[] shortGaussian2 = new double[sampleSize];
System.arraycopy(gaussian, 0, shortGaussian, 0, sampleSize);
System.arraycopy(gaussian, 10, shortGaussian2, 0, sampleSize);
final double[] d = {
test.kolmogorovSmirnovStatistic(shortGaussian, shortUniform),
test.kolmogorovSmirnovStatistic(shortGaussian2, shortGaussian)
};
for (double dv : d) {
double exactPStrict = test.exactP(dv, sampleSize, sampleSize, true);
double exactPNonStrict = test.exactP(dv, sampleSize, sampleSize, false);
double montePStrict = test.monteCarloP(dv, sampleSize, sampleSize, true,
KolmogorovSmirnovTest.MONTE_CARLO_ITERATIONS);
double montePNonStrict = test.monteCarloP(dv, sampleSize, sampleSize, false,
KolmogorovSmirnovTest.MONTE_CARLO_ITERATIONS);
Assert.assertEquals(exactPStrict, montePStrict, tol);
Assert.assertEquals(exactPNonStrict, montePNonStrict, tol);
}
}
开发者ID:Quanticol,项目名称:CARMA,代码行数:31,代码来源:KolmogorovSmirnovTestTest.java
示例18: create
import org.apache.commons.math3.random.Well19937c; //导入依赖的package包/类
@Override
public RandomNumberStream create(final RandomNumberStreamID id,
final Number seed)
{
final RandomGenerator rng = new Well19937c();
rng.setSeed(seed.intValue());
return RandomNumberStream.Util.asStream(id, rng);
}
开发者ID:krevelen,项目名称:coala,代码行数:9,代码来源:RandomNumberStreamFactoryWell19937c.java
示例19: precomputedGradient1FunctionWrapsPrecomputedValues
import org.apache.commons.math3.random.Well19937c; //导入依赖的package包/类
@Test
public void precomputedGradient1FunctionWrapsPrecomputedValues()
{
int n = 3;
RandomGenerator r = new Well19937c(30051977);
Gradient1Function f0 = new FakeGradientFunction(3, n);
int size = f0.size();
double[] b1 = new PseudoRandomGenerator(size, r).getSequence();
double[] b2 = new PseudoRandomGenerator(size, r).getSequence();
Gradient1Function f1 = PrecomputedGradient1Function.wrapGradient1Function(f0, b1);
Gradient1Function f2 = PrecomputedGradient1Function.wrapGradient1Function(f1, b2);
double[] p = new double[n];
for (int i = 0; i < n; i++)
p[i] = r.nextDouble();
double[] d0 = new double[n];
double[] d1 = new double[n];
double[] d2 = new double[n];
double[] v0 = evaluateGradient1Function(f0, p, d0);
double[] v1 = evaluateGradient1Function(f1, p, d1);
double[] v2 = evaluateGradient1Function(f2, p, d2);
for (int i = 0; i < v0.length; i++)
{
double e = v0[i] + b1[i] + b2[i];
double o1 = v1[i] + b2[i];
double o2 = v2[i];
Assert.assertEquals("o1", e, o1, 0);
Assert.assertEquals("o2", e, o2, 1e-6);
}
Assert.assertArrayEquals("d1", d0, d1, 0);
Assert.assertArrayEquals("d2", d0, d2, 0);
}
开发者ID:aherbert,项目名称:GDSC-SMLM,代码行数:32,代码来源:PrecomputedFunctionTest.java
示例20: generateBackgroundItemsets
import org.apache.commons.math3.random.Well19937c; //导入依赖的package包/类
/** Generate some disjoint itemsets as background noise */
public static HashMap<Itemset, Double> generateBackgroundItemsets(
final int noItemsets, final double p, final int noItems,
final double mu, final double sigma) {
final HashMap<Itemset, Double> backgroundItemsets = Maps.newHashMap();
final GeometricDistribution sizeDist = new GeometricDistribution(
new Well19937c(1), p);
final UniformIntegerDistribution itemDist = new UniformIntegerDistribution(
20, 20 + noItems - 1);
final LogNormalDistribution probDist = new LogNormalDistribution(
new Well19937c(1), mu, sigma);
while (backgroundItemsets.size() < noItemsets) {
final int len = sizeDist.sample() + 1; // use shifted geometric
final Itemset set = new Itemset();
for (int i = 0; i < len; i++) {
final int samp = itemDist.sample();
set.add(samp);
}
final double num = probDist.sample();
backgroundItemsets.put(set, num);
}
return backgroundItemsets;
}
开发者ID:mast-group,项目名称:itemset-mining,代码行数:28,代码来源:TransactionGenerator.java
注:本文中的org.apache.commons.math3.random.Well19937c类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论