Examples of Well1024a


Examples of org.apache.commons.math3.random.Well1024a

    @Test
    public void testLinearCombination2() {
        // we compare accurate versus naive dot product implementations
        // on regular vectors (i.e. not extreme cases like in the previous test)
        Well1024a random = new Well1024a(553267312521321234l);

        for (int i = 0; i < 10000; ++i) {
            final double ux = 1e17 * random.nextDouble();
            final double uy = 1e17 * random.nextDouble();
            final double uz = 1e17 * random.nextDouble();
            final double vx = 1e17 * random.nextDouble();
            final double vy = 1e17 * random.nextDouble();
            final double vz = 1e17 * random.nextDouble();
            final double sInline = MathArrays.linearCombination(ux, vx,
                                                                uy, vy,
                                                                uz, vz);
            final double sArray = MathArrays.linearCombination(new double[] {ux, uy, uz},
                                                               new double[] {vx, vy, vz});
View Full Code Here

Examples of org.apache.commons.math3.random.Well1024a

    @Test
    public void testShuffleTail() {
        final int[] orig = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
        final int[] list = orig.clone();
        final int start = 4;
        MathArrays.shuffle(list, start, MathArrays.Position.TAIL, new Well1024a(7654321L));

        // Ensure that all entries below index "start" did not move.
        for (int i = 0; i < start; i++) {
            Assert.assertEquals(orig[i], list[i]);
        }
View Full Code Here

Examples of org.apache.commons.math3.random.Well1024a

    @Test
    public void testShuffleHead() {
        final int[] orig = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
        final int[] list = orig.clone();
        final int start = 4;
        MathArrays.shuffle(list, start, MathArrays.Position.HEAD, new Well1024a(1234567L));

        // Ensure that all entries above index "start" did not move.
        for (int i = start + 1; i < orig.length; i++) {
            Assert.assertEquals(orig[i], list[i]);
        }
View Full Code Here

Examples of org.apache.commons.math3.random.Well1024a

        }
    }

    @Test
    public void testFloorDivModInt() {
        RandomGenerator generator = new Well1024a(0x7ccab45edeaab90al);
        for (int i = 0; i < 10000; ++i) {
            int a = generator.nextInt();
            int b = generator.nextInt();
            if (b == 0) {
                try {
                    FastMath.floorDiv(a, b);
                    Assert.fail("an exception should have been thrown");
                } catch (MathArithmeticException mae) {
View Full Code Here

Examples of org.apache.commons.math3.random.Well1024a

        }
    }

    @Test
    public void testFloorDivModLong() {
        RandomGenerator generator = new Well1024a(0xb87b9bc14c96ccd5l);
        for (int i = 0; i < 10000; ++i) {
            long a = generator.nextLong();
            long b = generator.nextLong();
            if (b == 0) {
                try {
                    FastMath.floorDiv(a, b);
                    Assert.fail("an exception should have been thrown");
                } catch (MathArithmeticException mae) {
View Full Code Here

Examples of org.apache.commons.math3.random.Well1024a

        checkAllTechniquesPercentile();
    }

    @Test
    public void testAllTechniquesPercentileUsingRandomPivoting() {
        kthSelector = new KthSelector(new RandomPivotingStrategy(new Well1024a(0x268a7fb4194240f6l)));
        Assert.assertEquals(RandomPivotingStrategy.class,
                            getUnivariateStatistic().getPivotingStrategy().getClass());
        checkAllTechniquesPercentile();
    }
View Full Code Here

Examples of org.apache.commons.math3.random.Well1024a

        Assert.assertEquals("Legacy Apache Commons Math",Percentile.EstimationType.LEGACY.getName());

        for (final PivotingStrategyInterface strategy : new PivotingStrategyInterface[] {
            new MedianOf3PivotingStrategy(),
            new CentralPivotingStrategy(),
            new RandomPivotingStrategy(new Well1024a(0xf097c734e4740053l))
        }) {
            kthSelector = new KthSelector(strategy);
            testAllEstimationTechniquesOnly();
        }
    }
View Full Code Here

Examples of org.apache.commons.math3.random.Well1024a

        Assert.assertTrue(ball.getRadius() > 0);
    }

    @Test
    public void testLargeSamples() throws IOException {
        RandomGenerator random = new Well1024a(0x35ddecfc78131e1dl);
        final UnitSphereRandomVectorGenerator sr = new UnitSphereRandomVectorGenerator(3, random);
        for (int k = 0; k < 50; ++k) {

            // define the reference sphere we want to compute
            double d = 25 * random.nextDouble();
            double refRadius = 10 * random.nextDouble();
            Vector3D refCenter = new Vector3D(d, new Vector3D(sr.nextVector()));
            // set up a large sample inside the reference sphere
            int nbPoints = random.nextInt(1000);
            List<Vector3D> points = new ArrayList<Vector3D>();
            for (int i = 0; i < nbPoints; ++i) {
                double r = refRadius * random.nextDouble();
                points.add(new Vector3D(1.0, refCenter, r, new Vector3D(sr.nextVector())));
            }

            // test we find a sphere at most as large as the one used for random drawings
            checkSphere(points, refRadius);
View Full Code Here

Examples of org.apache.commons.math3.random.Well1024a

        checkDisk(list, Arrays.asList(list.get(1), list.get(2), list.get(3)));
    }

    @Test
    public void testLargeSamples() {
        RandomGenerator random = new Well1024a(0xa2a63cad12c01fb2l);
        for (int k = 0; k < 100; ++k) {
            int nbPoints = random.nextInt(10000);
            List<Vector2D> points = new ArrayList<Vector2D>();
            for (int i = 0; i < nbPoints; ++i) {
                double x = random.nextDouble();
                double y = random.nextDouble();
                points.add(new Vector2D(x, y));
            }
            checkDisk(points);
        }
    }
View Full Code Here

Examples of org.apache.commons.math3.random.Well1024a

        Assert.assertEquals(3, disk.getSupportSize());
    }

    @Test
    public void testRandom() {
        final RandomGenerator random = new Well1024a(0x12faa818373ffe90l);
        final UnitSphereRandomVectorGenerator sr = new UnitSphereRandomVectorGenerator(2, random);
        for (int i = 0; i < 500; ++i) {
            double d = 25 * random.nextDouble();
            double refRadius = 10 * random.nextDouble();
            Vector2D refCenter = new Vector2D(d, new Vector2D(sr.nextVector()));
            List<Vector2D> support = new ArrayList<Vector2D>();
            for (int j = 0; j < 3; ++j) {
                support.add(new Vector2D(1.0, refCenter, refRadius, new Vector2D(sr.nextVector())));
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.