Example usage for org.apache.commons.math.random UncorrelatedRandomVectorGenerator nextVector

List of usage examples for org.apache.commons.math.random UncorrelatedRandomVectorGenerator nextVector

Introduction

In this page you can find the example usage for org.apache.commons.math.random UncorrelatedRandomVectorGenerator nextVector.

Prototype

public double[] nextVector() 

Source Link

Document

Generate an uncorrelated random vector.

Usage

From source file:com.tomgibara.cluster.CreateGaussianCross.java

private static void writeCluster(NormalizedRandomGenerator gen, double[] means, double[] deviations, int size,
        Writer writer) throws IOException {
    UncorrelatedRandomVectorGenerator c = new UncorrelatedRandomVectorGenerator(means, deviations, gen);
    for (int i = 0; i < size; i++) {
        double[] pt = c.nextVector();
        writer.write(String.format("%3.3f %3.3f%n", pt[0], pt[1]));
    }//  w  w  w .j  a v a 2  s  .  c o  m
}

From source file:com.tomgibara.cluster.CreateUniformCircles.java

private static void writeCluster(NormalizedRandomGenerator gen, double[] means, double[] deviations, int size,
        Writer writer) throws IOException {
    UncorrelatedRandomVectorGenerator c = new UncorrelatedRandomVectorGenerator(means, deviations, gen);
    int count = 0;
    while (count < size) {
        double[] pt = c.nextVector();
        double x = pt[0] - means[0];
        double y = pt[1] - means[1];
        if (x * x + y * y > deviations[0] * deviations[1])
            continue;
        writer.write(String.format("%3.3f %3.3f%n", pt[0], pt[1]));
        count++;/*from ww w  . j a  va  2s  .  co m*/
    }
}