Package org.apache.commons.math3.distribution

Examples of org.apache.commons.math3.distribution.UniformRealDistribution.sample()


        final double[] coeff = { 12.9, -3.4, 2.1 }; // 12.9 - 3.4 x + 2.1 x^2
        final PolynomialFunction f = new PolynomialFunction(coeff);

        // Collect data from a known polynomial.
        for (int i = 0; i < 100; i++) {
            final double x = rng.sample();
            fitter.addObservedPoint(x, f.value(x));
        }

        // Start fit from initial guesses that are far from the optimal values.
        final double[] best = fitter.fit(new double[] { -1e-20, 3e15, -5e25 });
View Full Code Here


        RandomDataImpl random = new RandomDataImpl();

        // Generate 10 distinct random values
        for (int i = 0; i < 10; i++) {
            final RealDistribution u = new UniformRealDistribution(i + 0.5, i + 0.75);
            original[i] = u.sample();
        }

        // Generate a random permutation, making sure it is not the identity
        boolean isIdentity = true;
        do {
View Full Code Here

        final double[] coeff = { 12.9, -3.4, 2.1 }; // 12.9 - 3.4 x + 2.1 x^2
        final PolynomialFunction f = new PolynomialFunction(coeff);

        // Collect data from a known polynomial.
        for (int i = 0; i < 100; i++) {
            final double x = rng.sample();
            fitter.addObservedPoint(x, f.value(x));
        }

        // Start fit from initial guesses that are far from the optimal values.
        final double[] best = fitter.fit(new double[] { -1e-20, 3e15, -5e25 });
View Full Code Here

        final double[] coeff = { 12.9, -3.4, 2.1 }; // 12.9 - 3.4 x + 2.1 x^2
        final PolynomialFunction f = new PolynomialFunction(coeff);

        // Collect data from a known polynomial.
        for (int i = 0; i < 100; i++) {
            final double x = rng.sample();
            fitter.addObservedPoint(x, f.value(x));
        }

        // Start fit from initial guesses that are far from the optimal values.
        final double[] best = fitter.fit(new double[] { -1e-20, 3e15, -5e25 });
View Full Code Here

        RandomDataImpl random = new RandomDataImpl();

        // Generate 10 distinct random values
        for (int i = 0; i < 10; i++) {
            final RealDistribution u = new UniformRealDistribution(i + 0.5, i + 0.75);
            original[i] = u.sample();
        }

        // Generate a random permutation, making sure it is not the identity
        boolean isIdentity = true;
        do {
View Full Code Here

        final double[] coeff = { 12.9, -3.4, 2.1 }; // 12.9 - 3.4 x + 2.1 x^2
        final PolynomialFunction f = new PolynomialFunction(coeff);

        // Collect data from a known polynomial.
        for (int i = 0; i < 100; i++) {
            final double x = rng.sample();
            fitter.addObservedPoint(x, f.value(x));
        }

        // Start fit from initial guesses that are far from the optimal values.
        final double[] best = fitter.fit(new double[] { -1e-20, 3e15, -5e25 });
View Full Code Here

     */
    private double[] generateSample() {
        final IntegerDistribution size = new UniformIntegerDistribution(10, 100);
        final RealDistribution randomData = new UniformRealDistribution(-100, 100);
        final int sampleSize = size.sample();
        final double[] out = randomData.sample(sampleSize);
        return out;
    }

    /**
     * Generates a partition of <sample> into up to 5 sequentially selected
View Full Code Here

 
    UniformRealDistribution uDist = new UniformRealDistribution(rng,0,1);
    Matrix U = new DenseMatrix(rows, cols);
    for (int r = 0; r < rows; r++) {
      for ( int c = 0; c < cols; c++ ) {
        U.set(r, c, uDist.sample());
      }
    }
   
    return U;
   
View Full Code Here

            TreeSet<Result> results = new TreeSet<>();
            int count = (int) (workCount[executorIndex].sample() * multiplier);
            long targetTotalElapsed = 0;
            long start = System.nanoTime();
            long baseTime;
            if (Math.random() > 0.5) baseTime = 2 * (long) (workTime.sample() * multiplier);
            else  baseTime = 0;
            for (int j = 0 ; j < count ; j++)
            {
                long time;
                if (baseTime == 0) time = (long) (workTime.sample() * multiplier);
 
View Full Code Here

            if (Math.random() > 0.5) baseTime = 2 * (long) (workTime.sample() * multiplier);
            else  baseTime = 0;
            for (int j = 0 ; j < count ; j++)
            {
                long time;
                if (baseTime == 0) time = (long) (workTime.sample() * multiplier);
                else time = (long) (baseTime * Math.random());
                if (time < minWorkTime)
                    time = minWorkTime;
                if (time > maxWorkTime)
                    time = maxWorkTime;
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.