Examples of RandomGenerator


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

        }
    }

    @Test
    public void testTransform() {
        RandomGenerator random = new Well1024a(0x16992fc4294bf2f1l);
        UnitSphereRandomVectorGenerator sphRandom = new UnitSphereRandomVectorGenerator(3, random);
        for (int i = 0; i < 100; ++i) {

            Rotation r = new Rotation(new Vector3D(sphRandom.nextVector()),
                                      FastMath.PI * random.nextDouble());
            Transform<Sphere2D, Sphere1D> t = Circle.getTransform(r);

            S2Point  p = new S2Point(new Vector3D(sphRandom.nextVector()));
            S2Point tp = (S2Point) t.apply(p);
            Assert.assertEquals(0.0, r.applyTo(p.getVector()).distance(tp.getVector()), 1.0e-10);

            Circle  c = new Circle(new Vector3D(sphRandom.nextVector()), 1.0e-10);
            Circle tc = (Circle) t.apply(c);
            Assert.assertEquals(0.0, r.applyTo(c.getPole()).distance(tc.getPole()),   1.0e-10);
            Assert.assertEquals(0.0, r.applyTo(c.getXAxis()).distance(tc.getXAxis()), 1.0e-10);
            Assert.assertEquals(0.0, r.applyTo(c.getYAxis()).distance(tc.getYAxis()), 1.0e-10);
            Assert.assertEquals(c.getTolerance(), ((Circle) t.apply(c)).getTolerance(), 1.0e-10);

            SubLimitAngle  sub = new LimitAngle(new S1Point(MathUtils.TWO_PI * random.nextDouble()),
                                                random.nextBoolean(), 1.0e-10).wholeHyperplane();
            Vector3D psub = c.getPointAt(((LimitAngle) sub.getHyperplane()).getLocation().getAlpha());
            SubLimitAngle tsub = (SubLimitAngle) t.apply(sub, c, tc);
            Vector3D ptsub = tc.getPointAt(((LimitAngle) tsub.getHyperplane()).getLocation().getAlpha());
            Assert.assertEquals(0.0, r.applyTo(psub).distance(ptsub), 1.0e-10);

View Full Code Here

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

        final BivariateFunction bcf
            = new BicubicSplineInterpolatingFunction(xval, yval, zval,
                                                     dZdX, dZdY, dZdXdY);
        double x, y;

        final RandomGenerator rng = new Well19937c(1234567L); // "tol" depends on the seed.
        final UniformRealDistribution distX
            = new UniformRealDistribution(rng, xval[0], xval[xval.length - 1]);
        final UniformRealDistribution distY
            = new UniformRealDistribution(rng, yval[0], yval[yval.length - 1]);
View Full Code Here

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

        BivariateFunction bcf = new BicubicSplineInterpolatingFunction(xval, yval, zval,
                                                                       dZdX, dZdY, dZdXdY);
        double x, y;

        final RandomGenerator rng = new Well19937c(1234567L); // "tol" depends on the seed.
        final UniformRealDistribution distX
            = new UniformRealDistribution(rng, xval[0], xval[xval.length - 1]);
        final UniformRealDistribution distY
            = new UniformRealDistribution(rng, yval[0], yval[yval.length - 1]);
View Full Code Here

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

        BivariateGridInterpolator interpolator = new BicubicSplineInterpolator();
        BivariateFunction p = interpolator.interpolate(xval, yval, zval);
        double x, y;

        final RandomGenerator rng = new Well19937c(1234567L); // "tol" depends on the seed.
        final UniformRealDistribution distX
            = new UniformRealDistribution(rng, xval[0], xval[xval.length - 1]);
        final UniformRealDistribution distY
            = new UniformRealDistribution(rng, yval[0], yval[yval.length - 1]);
View Full Code Here

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

        BivariateGridInterpolator interpolator = new BicubicSplineInterpolator();
        BivariateFunction p = interpolator.interpolate(xval, yval, zval);
        double x, y;

        final RandomGenerator rng = new Well19937c(1234567L); // "tol" depends on the seed.
        final UniformRealDistribution distX
            = new UniformRealDistribution(rng, xval[0], xval[xval.length - 1]);
        final UniformRealDistribution distY
            = new UniformRealDistribution(rng, yval[0], yval[yval.length - 1]);
View Full Code Here

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

        Assert.assertEquals(4, sphere.getSupportSize());
    }

    @Test
    public void testRandom() {
        final RandomGenerator random = new Well1024a(0xd015982e9f31ee04l);
        final UnitSphereRandomVectorGenerator sr = new UnitSphereRandomVectorGenerator(3, random);
        for (int i = 0; i < 100; ++i) {
            double d = 25 * random.nextDouble();
            double refRadius = 10 * random.nextDouble();
            Vector3D refCenter = new Vector3D(d, new Vector3D(sr.nextVector()));
            List<Vector3D> support = new ArrayList<Vector3D>();
            for (int j = 0; j < 5; ++j) {
                support.add(new Vector3D(1.0, refCenter, refRadius, new Vector3D(sr.nextVector())));
            }
View Full Code Here

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

*  - allow editing of the point set
*/
public class GeometryExample {

    public static List<Vector2D> createRandomPoints(int size) {
        RandomGenerator random = new MersenneTwister();

        // create the cloud container
        List<Vector2D> points = new ArrayList<Vector2D>(size);
        // fill the cloud with a random distribution of points
        for (int i = 0; i < size; i++) {
            points.add(new Vector2D(FastMath.round(random.nextDouble() * 400 + 100),
                    FastMath.round(random.nextDouble() * 400 + 100)));
        }
       
        return points;
    }
View Full Code Here

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

                                   new GammaDistribution(5, 1),
                                   new GammaDistribution(9, 0.5));
            container.add(comp, c);

            c.gridx++;
            RandomGenerator rng = new MersenneTwister(0);
            comp = createComponent("Levy", 0, 3,
                                   new String[] { "c=0.5", "c=1", "c=2", "c=4", "c=8" },
                                   new LevyDistribution(rng, 0, 0.5),
                                   new LevyDistribution(rng, 0, 1),
                                   new LevyDistribution(rng, 0, 2),
View Full Code Here

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

     * Creates a new random Polygon of the given length.
     */
    public static Polygon randomPolygon(int length) {
        final int polygonSize = 4 + 2 * length;

        final RandomGenerator random = GeneticAlgorithm.getRandomGenerator();
       
        Polygon p = new Polygon();
        p.data = new float[polygonSize];

        p.data[0] = random.nextFloat(); // r
        p.data[1] = random.nextFloat(); // g
        p.data[2] = random.nextFloat(); // b
        p.data[3] = FastMath.max(0.2f, random.nextFloat() * random.nextFloat()); // a
       
        float px = random.nextFloat();
        float py = random.nextFloat();
       
        for (int k = 0; k < length; k++) {
            p.data[4 + 2*k] = px + (random.nextFloat() - 0.5f);
            p.data[5 + 2*k] = py + (random.nextFloat() - 0.5f);
        }
        return p;
    }
View Full Code Here

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

           
            setLayout(new GridBagLayout());
           
            int nSamples = 1500;
           
            RandomGenerator rng = new Well19937c(0);
            List<List<DoublePoint>> datasets = new ArrayList<List<DoublePoint>>();

            datasets.add(normalize(makeCircles(nSamples, true, 0.04, 0.5, rng), -1, 1, -1, 1));
            datasets.add(normalize(makeMoons(nSamples, true, 0.04, rng), -1, 2, -1, 1));
            datasets.add(normalize(makeBlobs(nSamples, 3, 1.0, -10, 10, true, rng), -12, 12, -12, 12));
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.