Package org.apache.mahout.math.jet.random

Examples of org.apache.mahout.math.jet.random.AbstractContinousDistribution


    }

    @Test
    public void testSequentialPoints() {
        for (int i = 0; i < repeats(); i++) {
            runTest(factory, new AbstractContinousDistribution() {
                double base = 0;

                @Override
                public double nextDouble() {
                    base += Math.PI * 1e-5;
 
View Full Code Here


    @Test
    public void testNarrowNormal() {
        // this mixture of a uniform and normal distribution has a very narrow peak which is centered
        // near the median.  Our system should be scale invariant and work well regardless.
        final Random gen = RandomUtils.getRandom();
        AbstractContinousDistribution mix = new AbstractContinousDistribution() {
            AbstractContinousDistribution normal = new Normal(0, 1e-5, gen);
            AbstractContinousDistribution uniform = new Uniform(-1, 1, gen);

            @Override
            public double nextDouble() {
View Full Code Here

    @Test
    public void testRepeatedValues() {
        final Random gen = RandomUtils.getRandom();

        // 5% of samples will be 0 or 1.0.  10% for each of the values 0.1 through 0.9
        AbstractContinousDistribution mix = new AbstractContinousDistribution() {
            @Override
            public double nextDouble() {
                return Math.rint(gen.nextDouble() * 10) / 10.0;
            }
        };

        for (int run = 0; run < 3 * repeats(); run++) {
            TDigest dist = new ArrayDigest(32, (double) 1000);
            List<Double> data = Lists.newArrayList();
            for (int i1 = 0; i1 < 100000; i1++) {
                data.add(mix.nextDouble());
            }

            long t0 = System.nanoTime();
            for (double x : data) {
                dist.add(x);
View Full Code Here

    }

    @Test
    public void testSequentialPoints() {
        for (int i = 0; i < 3 * repeats(); i++) {
            runTest(factory, new AbstractContinousDistribution() {
                double base = 0;

                @Override
                public double nextDouble() {
                    base += Math.PI * 1e-5;
 
View Full Code Here

    @Test
    public void testNarrowNormal() {
        // this mixture of a uniform and normal distribution has a very narrow peak which is centered
        // near the median.  Our system should be scale invariant and work well regardless.
        final Random gen = RandomUtils.getRandom();
        AbstractContinousDistribution mix = new AbstractContinousDistribution() {
            AbstractContinousDistribution normal = new Normal(0, 1e-5, gen);
            AbstractContinousDistribution uniform = new Uniform(-1, 1, gen);

            @Override
            public double nextDouble() {
View Full Code Here

    @Test
    public void testRepeatedValues() {
        final Random gen = RandomUtils.getRandom();

        // 5% of samples will be 0 or 1.0.  10% for each of the values 0.1 through 0.9
        AbstractContinousDistribution mix = new AbstractContinousDistribution() {
            @Override
            public double nextDouble() {
                return Math.rint(gen.nextDouble() * 10) / 10.0;
            }
        };

        AVLTreeDigest dist = new AVLTreeDigest((double) 1000);
        List<Double> data = Lists.newArrayList();
        for (int i1 = 0; i1 < 100000; i1++) {
            double x = mix.nextDouble();
            data.add(x);
        }

        long t0 = System.nanoTime();
        for (double x : data) {
View Full Code Here

    }

    @Test
    public void testSequentialPoints() {
        for (int i = 0; i < repeats(); i++) {
            runTest(factory, new AbstractContinousDistribution() {
                double base = 0;

                @Override
                public double nextDouble() {
                    base += Math.PI * 1e-5;
 
View Full Code Here

    }

    @Override
    public DistributionWithMean nextDistribution() {
        final double p = bd.nextDouble();
        return new DistributionWithMean(new AbstractContinousDistribution() {
            @Override
            public double nextDouble() {
                return gen.nextDouble() < p ? 1 : 0;
            }
        }, p);
View Full Code Here

    public double getSamples() {
        return bd.getAlpha() + bd.getBeta();
    }

    private AbstractContinousDistribution createBernoulliDistribution(final double p) {
        return new AbstractContinousDistribution() {
            @Override
            public double nextDouble() {
                return gen.nextDouble() < p ? 1 : 0;
            }
        };
View Full Code Here

        assertEquals(2.0, gnd.nextSD(), 0.1);

        double[] x = new double[10000];
        double[] y = new double[10000];
        double[] z = new double[10000];
        AbstractContinousDistribution dist = gnd.posteriorDistribution();
        for (int i = 0; i < 10000; i++) {
            x[i] = gnd.nextDouble();
            y[i] = dist.nextDouble();
            z[i] = gen.nextGaussian() * 2 + 1;
        }

        Arrays.sort(x);
        Arrays.sort(y);
View Full Code Here

TOP

Related Classes of org.apache.mahout.math.jet.random.AbstractContinousDistribution

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.