Example usage for org.apache.commons.math.random GaussianRandomGenerator GaussianRandomGenerator

List of usage examples for org.apache.commons.math.random GaussianRandomGenerator GaussianRandomGenerator

Introduction

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

Prototype

public GaussianRandomGenerator(final RandomGenerator generator) 

Source Link

Document

Create a new generator.

Usage

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

public static void main(String[] args) throws IOException {
    GaussianRandomGenerator gen = new GaussianRandomGenerator(new JDKRandomGenerator());
    FileWriter writer = new FileWriter("R/gmouse.txt");
    try {//from www .  j a v  a  2  s . c  o  m
        writeCluster(gen, new double[] { 0, 0 }, new double[] { 4, 4 }, 100, writer);
        writeCluster(gen, new double[] { -4, 4 }, new double[] { 2, 2 }, 50, writer);
        writeCluster(gen, new double[] { 4, 4 }, new double[] { 2, 2 }, 50, writer);
    } finally {
        writer.close();
    }
}

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

public static void main(String[] args) throws IOException {
    GaussianRandomGenerator gen = new GaussianRandomGenerator(new JDKRandomGenerator());
    final double[] center = new double[] { 0, 0 };
    int clusterSize = 300;
    FileWriter writer = new FileWriter("R/cross.txt");
    try {/*from   w w  w .  jav  a  2s  . c om*/
        writeCluster(gen, center, new double[] { 6, 1 }, clusterSize, writer);
        writeCluster(gen, center, new double[] { 1, 6 }, clusterSize, writer);
    } finally {
        writer.close();
    }
}

From source file:org.apache.hadoop.hbase.regionserver.compactions.GaussianFileListGenerator.java

@Override
public Iterator<List<StoreFile>> iterator() {
    return new Iterator<List<StoreFile>>() {
        private GaussianRandomGenerator gen = new GaussianRandomGenerator(
                new MersenneTwister(random.nextInt()));
        private int count = 0;

        @Override/*  w ww.j a  v  a2s  .  co m*/
        public boolean hasNext() {
            return count < MAX_FILE_GEN_ITERS;
        }

        @Override
        public List<StoreFile> next() {
            count += 1;
            ArrayList<StoreFile> files = new ArrayList<StoreFile>(NUM_FILES_GEN);
            for (int i = 0; i < NUM_FILES_GEN; i++) {
                files.add(createMockStoreFile(
                        (int) Math.ceil(Math.max(0, gen.nextNormalizedDouble() * 32 + 32))));
            }

            return files;
        }

        @Override
        public void remove() {
        }
    };
}

From source file:org.apache.metron.common.math.stats.OnlineStatisticsProviderTest.java

@Test
public void testNormallyDistributedRandomData() {
    List<Double> values = new ArrayList<>();
    GaussianRandomGenerator gaussian = new GaussianRandomGenerator(new MersenneTwister(0L));
    for (int i = 0; i < 1000000; ++i) {
        double d = gaussian.nextNormalizedDouble();
        values.add(d);//from ww w .  j  a  v  a 2  s .  c o m
    }
    validateEquality(values);
}

From source file:org.apache.metron.common.math.stats.OnlineStatisticsProviderTest.java

@Test
public void testNormallyDistributedRandomDataShifted() {
    List<Double> values = new ArrayList<>();
    GaussianRandomGenerator gaussian = new GaussianRandomGenerator(new MersenneTwister(0L));
    for (int i = 0; i < 1000000; ++i) {
        double d = gaussian.nextNormalizedDouble() + 10;
        values.add(d);/*from w  w  w.  j  a v a 2s.co m*/
    }
    validateEquality(values);
}

From source file:org.apache.metron.common.math.stats.OnlineStatisticsProviderTest.java

@Test
public void testNormallyDistributedRandomDataShiftedBackwards() {
    List<Double> values = new ArrayList<>();
    GaussianRandomGenerator gaussian = new GaussianRandomGenerator(new MersenneTwister(0L));
    for (int i = 0; i < 1000000; ++i) {
        double d = gaussian.nextNormalizedDouble() - 10;
        values.add(d);//w w w .j  a  va 2 s .com
    }
    validateEquality(values);
}

From source file:org.apache.metron.common.math.stats.OnlineStatisticsProviderTest.java

@Test
public void testNormallyDistributedRandomDataSkewed() {
    List<Double> values = new ArrayList<>();
    GaussianRandomGenerator gaussian = new GaussianRandomGenerator(new MersenneTwister(0L));
    for (int i = 0; i < 1000000; ++i) {
        double d = (gaussian.nextNormalizedDouble() + 10000) / 1000;
        values.add(d);/* w  w  w.  ja  v a 2 s . c  o m*/
    }
    validateEquality(values);
}

From source file:org.apache.metron.common.math.stats.OnlineStatisticsProviderTest.java

@Test
public void testNormallyDistributedRandomDataAllNegative() {
    List<Double> values = new ArrayList<>();
    GaussianRandomGenerator gaussian = new GaussianRandomGenerator(new MersenneTwister(0L));
    for (int i = 0; i < 1000000; ++i) {
        double d = -1 * gaussian.nextNormalizedDouble();
        values.add(d);// w w  w  .ja  va 2s .  com
    }
    validateEquality(values);
}