Java Code Examples for java.util.concurrent.ThreadLocalRandom#nextGaussian()
The following examples show how to use
java.util.concurrent.ThreadLocalRandom#nextGaussian() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MonitoringEventSource.java From cep-monitoring with Apache License 2.0 | 6 votes |
public void run(SourceContext<MonitoringEvent> sourceContext) throws Exception { while (running) { MonitoringEvent monitoringEvent; final ThreadLocalRandom random = ThreadLocalRandom.current(); if (shard > 0) { int rackId = random.nextInt(shard) + offset; if (random.nextDouble() >= temperatureRatio) { double power = random.nextGaussian() * powerStd + powerMean; monitoringEvent = new PowerEvent(rackId, power); } else { double temperature = random.nextGaussian() * temperatureStd + temperatureMean; monitoringEvent = new TemperatureEvent(rackId, temperature); } sourceContext.collect(monitoringEvent); } Thread.sleep(pause); } }
Example 2
Source File: GenePvalueCalculator.java From systemsgenetics with GNU General Public License v3.0 | 6 votes |
/** * Fills a subset of the null * * @param geneChi2SumNull vector to fill will null chi2 values * @param eigenValues * @param randomChi2 reference distribution * @param start zero based count * @param stop zero based count, so must be < nrPermutation @return @param * rnd @pa r am eigenValuesLengt h */ public static void runPermutationsUsingEigenValues(final double[] geneChi2SumNull, final double[] eigenValues, double[] randomChi2, final int start, final int stop, final ThreadLocalRandom rnd, final int eigenValuesLength) { final int randomChi2Size = randomChi2.length; //LOGGER.debug("start: " + start + " stop: " + stop); int i = start; for (int perm = start; perm < stop; perm++) { double weightedChi2Perm = 0; for (int g = 0; g < eigenValuesLength; g++) { if (i < randomChi2Size) { weightedChi2Perm += eigenValues[g] * randomChi2[i++]; } else { double randomZ = rnd.nextGaussian(); weightedChi2Perm += eigenValues[g] * (randomZ * randomZ); } } geneChi2SumNull[perm] = weightedChi2Perm; } }
Example 3
Source File: BodyServiceImpl.java From retro-game with GNU Affero General Public License v3.0 | 5 votes |
private int generatePlanetDiameter(int position) { ThreadLocalRandom random = ThreadLocalRandom.current(); double x = Math.abs(8 - position); double mean = 200.0 - 10.0 * x; double sd = 60.0 - 5.0 * x; double numFields = mean + sd * random.nextGaussian(); numFields = Math.max(numFields, 42.0); return (int) (Math.sqrt(numFields) * 100.0) * 10; }
Example 4
Source File: BodyServiceImpl.java From retro-game with GNU Affero General Public License v3.0 | 5 votes |
private int generateTemperature(int position) { ThreadLocalRandom random = ThreadLocalRandom.current(); double x = 8 - position; double mean = 30.0 + 1.75 * Math.signum(x) * x * x; int temperature = (int) (mean + 10.0 * random.nextGaussian()); return Math.max(-60, Math.min(120, temperature)); }
Example 5
Source File: EstimateChi2SumDistUsingCorrelatedVariablesThread.java From systemsgenetics with GNU General Public License v3.0 | 5 votes |
@Override public double[] call() throws Exception { ThreadLocalRandom rnd = ThreadLocalRandom.current(); double[] geneChi2SumNull = new double[nrPermsThisTask]; for (int perm=0; perm<nrPermsThisTask; perm++) { double weightedChi2Perm = 0; for (int g=0; g<eigenValues.length; g++) { double randomZ = rnd.nextGaussian(); weightedChi2Perm+=eigenValues[g] * randomZ * randomZ; } geneChi2SumNull[perm]=weightedChi2Perm; } return geneChi2SumNull; }