Refine search
public static double [] startCoefs(int n, long seed){ double [] res = MemoryManager.malloc8d(n); Random r = new Random(seed); for(int i = 0; i < res.length; ++i) res[i] = r.nextGaussian(); return res; } }
private static ImmutableList<Double> generatePseudorandomDataset() { Random random = new Random(2211275185798966364L); ImmutableList.Builder<Double> largeDatasetBuilder = ImmutableList.builder(); for (int i = 0; i < PSEUDORANDOM_DATASET_SIZE; i++) { largeDatasetBuilder.add(random.nextGaussian()); } return largeDatasetBuilder.build(); }
public static void main(String[] args) { TrendLine t = new PolyTrendLine(2); Random rand = new Random(); double[] x = new double[1000*1000]; double[] err = new double[x.length]; double[] y = new double[x.length]; for (int i=0; i<x.length; i++) { x[i] = 1000*rand.nextDouble(); } for (int i=0; i<x.length; i++) { err[i] = 100*rand.nextGaussian(); } for (int i=0; i<x.length; i++) { y[i] = x[i]*x[i]+err[i]; } // quadratic model t.setValues(y,x); System.out.println(t.predict(12)); // when x=12, y should be... , eg 143.61380202745192 }
@Override public void setAngry(boolean angry) { if (!angry) { anger = 0; } else if (isAngry()) { anger = (int) (new Random().nextGaussian() * 400) + 400; } }
private int[] generateArray() { Random random = new Random(); List<Integer> ints = new ArrayList<>(size); int last = 0; for (int i = 0; i < size; ++i) { if (random.nextGaussian() > 1 - randomness) { last = last + 1; } else { last = last + 1 + random.nextInt(99); } ints.add(last); } Collections.shuffle(ints); int[] data = new int[size]; int i = 0; for (Integer value : ints) { data[i++] = value; } return data; }
/** * For testing only. * @param args Ignored */ public static void main(String[] args) { Random random = new Random(); int length = 100; double[] A = new double[length]; double[] B = new double[length]; double aAvg = 70.0; double bAvg = 70.5; for (int i = 0; i < length; i++) { A[i] = aAvg + random.nextGaussian(); B[i] = bAvg + random.nextGaussian(); } System.out.println("A has length " + A.length + " and mean " + mean(A)); System.out.println("B has length " + B.length + " and mean " + mean(B)); for (int t = 0; t < 10; t++) { System.out.println("p-value: " + sigLevelByApproxRand(A, B)); } }
private int[] generateArray(double runThreshold) { Random random = new Random(); int[] data = new int[size]; int last = 0; int i = 0; while (i < size) { if (random.nextGaussian() > runThreshold) { int runLength = random.nextInt(Math.min(size - i, 1 << 16)); for (int j = 0; j < runLength; ++j) { data[i + j] = last + 1; last = data[i + j]; } i += runLength; } else { data[i] = last + 1 + random.nextInt(999); last = data[i]; ++i; } } Arrays.sort(data); return data; }
final Random random = new Random(firstSeed); final String tmpDir = System.getProperty("java.io.tmpdir"); point[0] = random.nextGaussian(); point[1] = 2 * point[0] + 0.01 * random.nextGaussian(); writePoint(point, buffer, pointsOut);
@Setup(Level.Iteration) public void setup() { final Random r = new Random(1234567891L); dataIterator = Iterators.cycle( Stream.generate(() -> Math.round(Math.exp(2.0 + r.nextGaussian()))).limit(1048576) .collect(Collectors.toList())); } }
public static void gauss(double[][] goals, double[][] array) { Random rand = new Random(SEED); for( int r = 0; r < array.length; r++ ) { final int goal = rand.nextInt(goals.length); for( int c = 0; c < array[r].length; c++ ) array[r][c] = goals[goal][c] + rand.nextGaussian() * SIGMA; } }
public static Dataset getDataset() { int datapoints = 100; List<Double> labels = new ArrayList<>(); List<FeatureVector> features = new ArrayList<>(); Random rand = new Random(0); for (int i = 0; i < datapoints; i++) { double label = rand.nextDouble() < 0.5 ? 0 : 1; labels.add(label); features.add(new FeatureVector(0, label + rand.nextGaussian())); } return new Dataset(labels, features, ImmutableMap.of(0, "first", 1, "second")); } }
final Random random = new Random(firstSeed); point[d] = (random.nextGaussian() * absoluteStdDev) + centroid[d];
public void onRandomize() { Random random = new Random(); habit.getRepetitions().removeAll(); double strength = 50; for (int i = 0; i < 365 * 5; i++) { if (i % 7 == 0) strength = max(0, min(100, strength + 10 * random.nextGaussian())); if (random.nextInt(100) > strength) continue; int value = 1; if (habit.isNumerical()) value = (int) (1000 + 250 * random.nextGaussian() * strength / 100) * 1000; habit.getRepetitions().add(new Repetition(DateUtils.getToday().minus(i), value)); } habit.invalidateNewerThan(Timestamp.ZERO); }
private PercentileAggregator createPercentileAggreator(int sumNums, Integer sqrtNum, Integer compression) { compression = compression == null ? DEFAULT_COMPRESSION : compression; PercentileAggregator aggregator = new PercentileAggregator(compression); Random random = new Random(); for (int i = 0; i < sumNums; i++) { double d = 0; if (sqrtNum == null) d = random.nextInt(1000000000); else d = Math.sqrt(sqrtNum.intValue()) * random.nextGaussian(); PercentileCounter c = new PercentileCounter(compression, 0.5); c.add(d); aggregator.aggregate(c); } return aggregator; }
final int numRand = 10000; ApproximateHistogram h = new ApproximateHistogram(combinedHistSize); Random rand = new Random(0); Float[] randNums = new Float[numRand]; for (int i = 0; i < numRand; i++) { randNums[i] = (float) rand.nextGaussian(); ApproximateHistogram tmp = new ApproximateHistogram(histSize); for (int i = 0; i < 20; ++i) { tmp.offer((float) (rand.nextGaussian() + (double) k));
private static final int FAST = 100; private static final int SLOW = FAST * 5; private static final Random random = new Random(); private Timer timer; return (float) (random.nextGaussian() * MINMAX / 3);
private static Page getPage() { Type mapType = typeManager.getParameterizedType("map", ImmutableList.of(TypeSignatureParameter.of(parseTypeSignature(StandardTypes.BIGINT)), TypeSignatureParameter.of(parseTypeSignature(StandardTypes.DOUBLE)))); int datapoints = 100; RowPageBuilder builder = RowPageBuilder.rowPageBuilder(BIGINT, mapType, VarcharType.VARCHAR); Random rand = new Random(0); for (int i = 0; i < datapoints; i++) { long label = rand.nextDouble() < 0.5 ? 0 : 1; builder.row(label, mapBlockOf(BIGINT, DOUBLE, 0L, label + rand.nextGaussian()), "C=1"); } return builder.build(); } }
XYSeriesCollection xySeriesCollection = new XYSeriesCollection(); XYSeries series = new XYSeries("Random"); Random rand = new Random(); for (int i = 0; i < values.length; i++) { for (int j = 0; j < values[i].length; j++) { double x = rand.nextGaussian(); double y = rand.nextGaussian(); series.add(x, y);
Random r = new Random(); double mySample = r.nextGaussian()*desiredStandardDeviation+desiredMean;
public static Matrix randomHierarchicalMatrix(int numRows, int numCols, boolean symmetric) { Matrix matrix = new DenseMatrix(numRows, numCols); // TODO rejigger tests so that it doesn't expect this particular seed Random r = new Random(1234L); for (int row = 0; row < numRows; row++) { Vector v = new DenseVector(numCols); for (int col = 0; col < numCols; col++) { double val = r.nextGaussian(); v.set(col, val); } v.assign(Functions.MULT, 1/((row + 1) * v.norm(2))); matrix.assignRow(row, v); } if (symmetric) { return matrix.times(matrix.transpose()); } return matrix; }