org.apache.commons.math3.random.Well19937c Java Examples

The following examples show how to use org.apache.commons.math3.random.Well19937c. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PatternSeasonalGenerator.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
public PatternSeasonalGenerator(double mean, double sigma, double trend, double wavelength, double amplitude,
                                double offset, int seed, double[] scalingFactors) {
    this.trend = trend;
    this.wavelength = wavelength;
    this.amplitude = amplitude;
    this.offset = offset;
    this.scalingFactors = scalingFactors;

    this.generator = new NormalDistribution(new Well19937c(seed), mean, sigma, 1.0E-9D);
}
 
Example #2
Source File: MockEventsLoader.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
/**
 * Return a pre-configured distribution given a set of configuration parameters.
 *
 * @param type distribution type
 * @param param main param (usually mean)
 * @param seed RNG seed
 * @return distribution
 */
AbstractRealDistribution makeDist(String type, double param, int seed) {
    switch (type.toLowerCase()) {
        case DIST_TYPE_FIXED:
            return new UniformRealDistribution(param, param + 0.001);
        case DIST_TYPE_GAUSSIAN:
            return new NormalDistribution(new Well19937c(seed), param, 1.0d, 1.0E-9D);
        case DIST_TYPE_EXPONENTIAL:
            return new ExponentialDistribution(new Well19937c(seed), param, 1.0E-9D);
        case DIST_TYPE_LOGNORMAL:
            return new LogNormalDistribution(new Well19937c(seed), param, 1.0d, 1.0E-9D);
        default:
            throw new IllegalArgumentException(String.format("Unsupported distribution type '%s'", type));
    }
}
 
Example #3
Source File: GaussianNoiseOneMasker.java    From jstarcraft-ai with Apache License 2.0 5 votes vote down vote up
@Override
public void mask(MathMatrix matrix, int iteration, int epoch) {
    float current = schedule.valueAt(iteration, epoch);
    current = (float) Math.sqrt(current / (1F - current));

    QuantityProbability probability = new QuantityProbability(Well19937c.class, 0, NormalDistribution.class, 1F, current);
    matrix.iterateElement(MathCalculator.PARALLEL, (scalar) -> {
        float value = scalar.getValue();
        scalar.setValue(value * probability.sample().floatValue());
    });
}
 
Example #4
Source File: KolmogorovSmirnovTestTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Verifies that Monte Carlo simulation gives results close to exact p values. This test is a
 * little long-running (more than two minutes on a fast machine), so is disabled by default.
 */
// @Test
public void testTwoSampleMonteCarlo() {
    final KolmogorovSmirnovTest test = new KolmogorovSmirnovTest(new Well19937c(1000));
    final int sampleSize = 14;
    final double tol = .001;
    final double[] shortUniform = new double[sampleSize];
    System.arraycopy(uniform, 0, shortUniform, 0, sampleSize);
    final double[] shortGaussian = new double[sampleSize];
    final double[] shortGaussian2 = new double[sampleSize];
    System.arraycopy(gaussian, 0, shortGaussian, 0, sampleSize);
    System.arraycopy(gaussian, 10, shortGaussian2, 0, sampleSize);
    final double[] d = {
        test.kolmogorovSmirnovStatistic(shortGaussian, shortUniform),
        test.kolmogorovSmirnovStatistic(shortGaussian2, shortGaussian)
    };
    for (double dv : d) {
        double exactPStrict = test.exactP(dv, sampleSize, sampleSize, true);
        double exactPNonStrict = test.exactP(dv, sampleSize, sampleSize, false);
        double montePStrict = test.monteCarloP(dv, sampleSize, sampleSize, true,
                                               KolmogorovSmirnovTest.MONTE_CARLO_ITERATIONS);
        double montePNonStrict = test.monteCarloP(dv, sampleSize, sampleSize, false,
                                                  KolmogorovSmirnovTest.MONTE_CARLO_ITERATIONS);
        Assert.assertEquals(exactPStrict, montePStrict, tol);
        Assert.assertEquals(exactPNonStrict, montePNonStrict, tol);
    }
}
 
Example #5
Source File: PiecewiseBicubicSplineInterpolatorTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
     * Interpolating a plane.
     * <p>
     * z = 2 x - 3 y + 5
     */
    @Test
    public void testInterpolation1() {
        final int sz = 21;
        double[] xval = new double[sz];
        double[] yval = new double[sz];
        // Coordinate values
        final double delta = 1d / (sz - 1);
        for ( int i = 0; i < sz; i++ ){
            xval[i] = -1 + 15 * i * delta;
            yval[i] = -20 + 30 * i * delta;
        }

        // Function values
        BivariateFunction f = new BivariateFunction() {
                public double value( double x, double y ) {
                    return 2 * x - 3 * y + 5;
                }
            };
        double[][] zval = new double[xval.length][yval.length];
        for ( int i = 0; i < xval.length; i++ ) {
            for ( int j = 0; j < yval.length; j++ ) {
                zval[i][j] = f.value(xval[i], yval[j]);
            }
        }

        BivariateGridInterpolator interpolator = new PiecewiseBicubicSplineInterpolator();
        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] );

        final int numSamples = 50;
        final double tol = 2e-14;
        for ( int i = 0; i < numSamples; i++ ) {
            x = distX.sample();
            for ( int j = 0; j < numSamples; j++ ) {
                y = distY.sample();
//                 System.out.println(x + " " + y + " " + f.value(x, y) + " " + p.value(x, y));
                Assert.assertEquals(f.value(x, y),  p.value(x, y), tol);
            }
//             System.out.println();
        }
    }
 
Example #6
Source File: BicubicSplineInterpolatingFunctionTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
     * Interpolating a plane.
     * <p>
     * z = 2 x - 3 y + 5
     */
    @Test
    public void testInterpolation1() {
        final int sz = 21;
        double[] xval = new double[sz];
        double[] yval = new double[sz];
        // Coordinate values
        final double delta = 1d / (sz - 1);
        for (int i = 0; i < sz; i++) {
            xval[i] = -1 + 15 * i * delta;
            yval[i] = -20 + 30 * i * delta;
        }

        // Function values
        BivariateFunction f = new BivariateFunction() {
                public double value(double x, double y) {
                    return 2 * x - 3 * y + 5;
                }
            };
        double[][] zval = new double[xval.length][yval.length];
        for (int i = 0; i < xval.length; i++) {
            for (int j = 0; j < yval.length; j++) {
                zval[i][j] = f.value(xval[i], yval[j]);
            }
        }
        // Partial derivatives with respect to x
        double[][] dZdX = new double[xval.length][yval.length];
        for (int i = 0; i < xval.length; i++) {
            for (int j = 0; j < yval.length; j++) {
                dZdX[i][j] = 2;
            }
        }
        // Partial derivatives with respect to y
        double[][] dZdY = new double[xval.length][yval.length];
        for (int i = 0; i < xval.length; i++) {
            for (int j = 0; j < yval.length; j++) {
                dZdY[i][j] = -3;
            }
        }
        // Partial cross-derivatives
        double[][] dZdXdY = new double[xval.length][yval.length];
        for (int i = 0; i < xval.length; i++) {
            for (int j = 0; j < yval.length; j++) {
                dZdXdY[i][j] = 0;
            }
        }

        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]);

        final int numSamples = 50;
        final double tol = 6;
        for (int i = 0; i < numSamples; i++) {
            x = distX.sample();
            for (int j = 0; j < numSamples; j++) {
                y = distY.sample();
//                 System.out.println(x + " " + y + " " + f.value(x, y) + " " + bcf.value(x, y));
                Assert.assertEquals(f.value(x, y),  bcf.value(x, y), tol);
            }
//             System.out.println();
        }
    }
 
Example #7
Source File: BicubicSplineInterpolatorTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
     * Interpolating a paraboloid.
     * <p>
     * z = 2 x<sup>2</sup> - 3 y<sup>2</sup> + 4 x y - 5
     */
    @Test
    public void testInterpolation2() {
        final int sz = 21;
        double[] xval = new double[sz];
        double[] yval = new double[sz];
        // Coordinate values
        final double delta = 1d / (sz - 1);
        for (int i = 0; i < sz; i++) {
            xval[i] = -1 + 15 * i * delta;
            yval[i] = -20 + 30 * i * delta;
        }

        // Function values
        BivariateFunction f = new BivariateFunction() {
                public double value(double x, double y) {
                    return 2 * x * x - 3 * y * y + 4 * x * y - 5;
                }
            };
        double[][] zval = new double[xval.length][yval.length];
        for (int i = 0; i < xval.length; i++) {
            for (int j = 0; j < yval.length; j++) {
                zval[i][j] = f.value(xval[i], yval[j]);
            }
        }

        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]);

        final int numSamples = 50;
        final double tol = 251;
        for (int i = 0; i < numSamples; i++) {
            x = distX.sample();
            for (int j = 0; j < numSamples; j++) {
                y = distY.sample();
//                 System.out.println(x + " " + y + " " + f.value(x, y) + " " + p.value(x, y));
                Assert.assertEquals(f.value(x, y),  p.value(x, y), tol);
            }
//             System.out.println();
        }
    }
 
Example #8
Source File: BicubicSplineInterpolatorTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
     * Interpolating a paraboloid.
     * <p>
     * z = 2 x<sup>2</sup> - 3 y<sup>2</sup> + 4 x y - 5
     */
    @Test
    public void testInterpolation2() {
        final int sz = 21;
        double[] xval = new double[sz];
        double[] yval = new double[sz];
        // Coordinate values
        final double delta = 1d / (sz - 1);
        for (int i = 0; i < sz; i++) {
            xval[i] = -1 + 15 * i * delta;
            yval[i] = -20 + 30 * i * delta;
        }

        // Function values
        BivariateFunction f = new BivariateFunction() {
                public double value(double x, double y) {
                    return 2 * x * x - 3 * y * y + 4 * x * y - 5;
                }
            };
        double[][] zval = new double[xval.length][yval.length];
        for (int i = 0; i < xval.length; i++) {
            for (int j = 0; j < yval.length; j++) {
                zval[i][j] = f.value(xval[i], yval[j]);
            }
        }

        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]);

        final int numSamples = 50;
        final double tol = 251;
        for (int i = 0; i < numSamples; i++) {
            x = distX.sample();
            for (int j = 0; j < numSamples; j++) {
                y = distY.sample();
//                 System.out.println(x + " " + y + " " + f.value(x, y) + " " + p.value(x, y));
                Assert.assertEquals(f.value(x, y),  p.value(x, y), tol);
            }
//             System.out.println();
        }
    }
 
Example #9
Source File: BicubicSplineInterpolatorTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
     * Interpolating a plane.
     * <p>
     * z = 2 x - 3 y + 5
     */
    @Test
    public void testInterpolation1() {
        final int sz = 21;
        double[] xval = new double[sz];
        double[] yval = new double[sz];
        // Coordinate values
        final double delta = 1d / (sz - 1);
        for (int i = 0; i < sz; i++) {
            xval[i] = -1 + 15 * i * delta;
            yval[i] = -20 + 30 * i * delta;
        }

        // Function values
        BivariateFunction f = new BivariateFunction() {
                public double value(double x, double y) {
                    return 2 * x - 3 * y + 5;
                }
            };
        double[][] zval = new double[xval.length][yval.length];
        for (int i = 0; i < xval.length; i++) {
            for (int j = 0; j < yval.length; j++) {
                zval[i][j] = f.value(xval[i], yval[j]);
            }
        }

        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]);

        final int numSamples = 50;
        final double tol = 6;
        for (int i = 0; i < numSamples; i++) {
            x = distX.sample();
            for (int j = 0; j < numSamples; j++) {
                y = distY.sample();
//                 System.out.println(x + " " + y + " " + f.value(x, y) + " " + p.value(x, y));
                Assert.assertEquals(f.value(x, y),  p.value(x, y), tol);
            }
//             System.out.println();
        }
    }
 
Example #10
Source File: BicubicSplineInterpolatorTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
     * Interpolating a plane.
     * <p>
     * z = 2 x - 3 y + 5
     */
    @Test
    public void testInterpolation1() {
        final int sz = 21;
        double[] xval = new double[sz];
        double[] yval = new double[sz];
        // Coordinate values
        final double delta = 1d / (sz - 1);
        for (int i = 0; i < sz; i++) {
            xval[i] = -1 + 15 * i * delta;
            yval[i] = -20 + 30 * i * delta;
        }

        // Function values
        BivariateFunction f = new BivariateFunction() {
                public double value(double x, double y) {
                    return 2 * x - 3 * y + 5;
                }
            };
        double[][] zval = new double[xval.length][yval.length];
        for (int i = 0; i < xval.length; i++) {
            for (int j = 0; j < yval.length; j++) {
                zval[i][j] = f.value(xval[i], yval[j]);
            }
        }

        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]);

        final int numSamples = 50;
        final double tol = 6;
        for (int i = 0; i < numSamples; i++) {
            x = distX.sample();
            for (int j = 0; j < numSamples; j++) {
                y = distY.sample();
//                 System.out.println(x + " " + y + " " + f.value(x, y) + " " + p.value(x, y));
                Assert.assertEquals(f.value(x, y),  p.value(x, y), tol);
            }
//             System.out.println();
        }
    }
 
Example #11
Source File: BicubicInterpolatingFunctionTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @param minimumX Lower bound of interpolation range along the x-coordinate.
 * @param maximumX Higher bound of interpolation range along the x-coordinate.
 * @param minimumY Lower bound of interpolation range along the y-coordinate.
 * @param maximumY Higher bound of interpolation range along the y-coordinate.
 * @param numberOfElements Number of data points (along each dimension).
 * @param numberOfSamples Number of test points.
 * @param f Function to test.
 * @param dfdx Partial derivative w.r.t. x of the function to test.
 * @param dfdy Partial derivative w.r.t. y of the function to test.
 * @param d2fdxdy Second partial cross-derivative of the function to test.
 * @param meanTolerance Allowed average error (mean error on all interpolated values).
 * @param maxTolerance Allowed error on each interpolated value.
 */
private void testInterpolation(double minimumX,
                               double maximumX,
                               double minimumY,
                               double maximumY,
                               int numberOfElements,
                               int numberOfSamples,
                               BivariateFunction f,
                               BivariateFunction dfdx,
                               BivariateFunction dfdy,
                               BivariateFunction d2fdxdy,
                               double meanTolerance,
                               double maxTolerance,
                               boolean print) {
    double expected;
    double actual;
    double currentX;
    double currentY;
    final double deltaX = (maximumX - minimumX) / numberOfElements;
    final double deltaY = (maximumY - minimumY) / numberOfElements;
    final double[] xValues = new double[numberOfElements];
    final double[] yValues = new double[numberOfElements];
    final double[][] zValues = new double[numberOfElements][numberOfElements];
    final double[][] dzdx = new double[numberOfElements][numberOfElements];
    final double[][] dzdy = new double[numberOfElements][numberOfElements];
    final double[][] d2zdxdy = new double[numberOfElements][numberOfElements];

    for (int i = 0; i < numberOfElements; i++) {
        xValues[i] = minimumX + deltaX * i;
        final double x = xValues[i];
        for (int j = 0; j < numberOfElements; j++) {
            yValues[j] = minimumY + deltaY * j;
            final double y = yValues[j];
            zValues[i][j] = f.value(x, y);
            dzdx[i][j] = dfdx.value(x, y);
            dzdy[i][j] = dfdy.value(x, y);
            d2zdxdy[i][j] = d2fdxdy.value(x, y);
        }
    }

    final BivariateFunction interpolation
        = new BicubicInterpolatingFunction(xValues,
                                           yValues,
                                           zValues,
                                           dzdx,
                                           dzdy,
                                           d2zdxdy);

    for (int i = 0; i < numberOfElements; i++) {
        currentX = xValues[i];
        for (int j = 0; j < numberOfElements; j++) {
            currentY = yValues[j];
            expected = f.value(currentX, currentY);
            actual = interpolation.value(currentX, currentY);
            Assert.assertTrue("On data point: " + expected + " != " + actual,
                              Precision.equals(expected, actual));
        }
    }

    final RandomGenerator rng = new Well19937c(1234567L);
    final UniformRealDistribution distX = new UniformRealDistribution(rng, xValues[0], xValues[xValues.length - 1]);
    final UniformRealDistribution distY = new UniformRealDistribution(rng, yValues[0], yValues[yValues.length - 1]);

    double sumError = 0;
    for (int i = 0; i < numberOfSamples; i++) {
        currentX = distX.sample();
        currentY = distY.sample();
        expected = f.value(currentX, currentY);

        if (print) {
            System.out.println(currentX + " " + currentY + " -> ");
        }

        actual = interpolation.value(currentX, currentY);
        sumError += FastMath.abs(actual - expected);

        if (print) {
            System.out.println(actual + " (diff=" + (expected - actual) + ")");
        }

        Assert.assertEquals(expected, actual, maxTolerance);
    }

    final double meanError = sumError / numberOfSamples;
    Assert.assertEquals(0, meanError, meanTolerance);
}
 
Example #12
Source File: FDistribution.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Creates an F distribution using the given degrees of freedom
 * and inverse cumulative probability accuracy.
 *
 * @param numeratorDegreesOfFreedom Numerator degrees of freedom.
 * @param denominatorDegreesOfFreedom Denominator degrees of freedom.
 * @param inverseCumAccuracy the maximum absolute error in inverse
 * cumulative probability estimates.
 * @throws NotStrictlyPositiveException if
 * {@code numeratorDegreesOfFreedom <= 0} or
 * {@code denominatorDegreesOfFreedom <= 0}.
 * @since 2.1
 */
public FDistribution(double numeratorDegreesOfFreedom,
                     double denominatorDegreesOfFreedom,
                     double inverseCumAccuracy)
    throws NotStrictlyPositiveException {
    this(new Well19937c(), numeratorDegreesOfFreedom,
         denominatorDegreesOfFreedom, inverseCumAccuracy);
}
 
Example #13
Source File: Math_11_MultivariateNormalDistribution_s.java    From coming with MIT License 3 votes vote down vote up
/**
 * Creates a multivariate normal distribution with the given mean vector and
 * covariance matrix.
 * <br/>
 * The number of dimensions is equal to the length of the mean vector
 * and to the number of rows and columns of the covariance matrix.
 * It is frequently written as "p" in formulae.
 *
 * @param means Vector of means.
 * @param covariances Covariance matrix.
 * @throws DimensionMismatchException if the arrays length are
 * inconsistent.
 * @throws SingularMatrixException if the eigenvalue decomposition cannot
 * be performed on the provided covariance matrix.
 * @throws NonPositiveDefiniteMatrixException if any of the eigenvalues is
 * negative.
 */
public MultivariateNormalDistribution(final double[] means,
                                      final double[][] covariances)
    throws SingularMatrixException,
           DimensionMismatchException,
           NonPositiveDefiniteMatrixException {
    this(new Well19937c(), means, covariances);
}
 
Example #14
Source File: UniformIntegerDistribution.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Creates a new uniform integer distribution using the given lower and
 * upper bounds (both inclusive).
 * <p>
 * <b>Note:</b> this constructor will implicitly create an instance of
 * {@link Well19937c} as random generator to be used for sampling only (see
 * {@link #sample()} and {@link #sample(int)}). In case no sampling is
 * needed for the created distribution, it is advised to pass {@code null}
 * as random generator via the appropriate constructors to avoid the
 * additional initialisation overhead.
 *
 * @param lower Lower bound (inclusive) of this distribution.
 * @param upper Upper bound (inclusive) of this distribution.
 * @throws NumberIsTooLargeException if {@code lower >= upper}.
 */
public UniformIntegerDistribution(int lower, int upper)
    throws NumberIsTooLargeException {
    this(new Well19937c(), lower, upper);
}
 
Example #15
Source File: ParetoDistribution.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Create a Pareto distribution using the specified scale, shape and
 * inverse cumulative distribution accuracy.
 *
 * @param scale the scale parameter of this distribution
 * @param shape the shape parameter of this distribution
 * @param inverseCumAccuracy Inverse cumulative probability accuracy.
 * @throws NotStrictlyPositiveException if {@code scale <= 0} or {@code shape <= 0}.
 */
public ParetoDistribution(double scale, double shape, double inverseCumAccuracy)
    throws NotStrictlyPositiveException {
    this(new Well19937c(), scale, shape, inverseCumAccuracy);
}
 
Example #16
Source File: HypergeometricDistribution.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Construct a new hypergeometric distribution with the specified population
 * size, number of successes in the population, and sample size.
 *
 * @param populationSize Population size.
 * @param numberOfSuccesses Number of successes in the population.
 * @param sampleSize Sample size.
 * @throws NotPositiveException if {@code numberOfSuccesses < 0}.
 * @throws NotStrictlyPositiveException if {@code populationSize <= 0}.
 * @throws NumberIsTooLargeException if {@code numberOfSuccesses > populationSize},
 * or {@code sampleSize > populationSize}.
 */
public HypergeometricDistribution(int populationSize, int numberOfSuccesses, int sampleSize)
throws NotPositiveException, NotStrictlyPositiveException, NumberIsTooLargeException {
    this(new Well19937c(), populationSize, numberOfSuccesses, sampleSize);
}
 
Example #17
Source File: PoissonDistribution.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Creates a new Poisson distribution with specified mean, convergence
 * criterion and maximum number of iterations.
 * <p>
 * <b>Note:</b> this constructor will implicitly create an instance of
 * {@link Well19937c} as random generator to be used for sampling only (see
 * {@link #sample()} and {@link #sample(int)}). In case no sampling is
 * needed for the created distribution, it is advised to pass {@code null}
 * as random generator via the appropriate constructors to avoid the
 * additional initialisation overhead.
 *
 * @param p Poisson mean.
 * @param epsilon Convergence criterion for cumulative probabilities.
 * @param maxIterations the maximum number of iterations for cumulative
 * probabilities.
 * @throws NotStrictlyPositiveException if {@code p <= 0}.
 * @since 2.1
 */
public PoissonDistribution(double p, double epsilon, int maxIterations)
throws NotStrictlyPositiveException {
    this(new Well19937c(), p, epsilon, maxIterations);
}
 
Example #18
Source File: WeibullDistribution.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Create a Weibull distribution with the given shape, scale and inverse
 * cumulative probability accuracy and a location equal to zero.
 * <p>
 * <b>Note:</b> this constructor will implicitly create an instance of
 * {@link Well19937c} as random generator to be used for sampling only (see
 * {@link #sample()} and {@link #sample(int)}). In case no sampling is
 * needed for the created distribution, it is advised to pass {@code null}
 * as random generator via the appropriate constructors to avoid the
 * additional initialisation overhead.
 *
 * @param alpha Shape parameter.
 * @param beta Scale parameter.
 * @param inverseCumAccuracy Maximum absolute error in inverse
 * cumulative probability estimates
 * (defaults to {@link #DEFAULT_INVERSE_ABSOLUTE_ACCURACY}).
 * @throws NotStrictlyPositiveException if {@code alpha <= 0} or
 * {@code beta <= 0}.
 * @since 2.1
 */
public WeibullDistribution(double alpha, double beta,
                           double inverseCumAccuracy) {
    this(new Well19937c(), alpha, beta, inverseCumAccuracy);
}
 
Example #19
Source File: PoissonDistribution.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Creates a new Poisson distribution with specified mean, convergence
 * criterion and maximum number of iterations.
 *
 * @param p Poisson mean.
 * @param epsilon Convergence criterion for cumulative probabilities.
 * @param maxIterations the maximum number of iterations for cumulative
 * probabilities.
 * @throws NotStrictlyPositiveException if {@code p <= 0}.
 * @since 2.1
 */
public PoissonDistribution(double p, double epsilon, int maxIterations)
throws NotStrictlyPositiveException {
    this(new Well19937c(), p, epsilon, maxIterations);
}
 
Example #20
Source File: UniformRealDistribution.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Create a uniform distribution.
 *
 * @param lower Lower bound of this distribution (inclusive).
 * @param upper Upper bound of this distribution (exclusive).
 * @param inverseCumAccuracy Inverse cumulative probability accuracy.
 * @throws NumberIsTooLargeException if {@code lower >= upper}.
 * @deprecated as of 3.2, inverse CDF is now calculated analytically, use
 *             {@link #UniformRealDistribution(double, double)} instead.
 */
@Deprecated
public UniformRealDistribution(double lower, double upper, double inverseCumAccuracy)
    throws NumberIsTooLargeException {
    this(new Well19937c(), lower, upper);
}
 
Example #21
Source File: LogNormalDistribution.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Create a log-normal distribution using the specified scale, shape and
 * inverse cumulative distribution accuracy.
 *
 * @param scale the scale parameter of this distribution
 * @param shape the shape parameter of this distribution
 * @param inverseCumAccuracy Inverse cumulative probability accuracy.
 * @throws NotStrictlyPositiveException if {@code shape <= 0}.
 */
public LogNormalDistribution(double scale, double shape, double inverseCumAccuracy)
    throws NotStrictlyPositiveException {
    this(new Well19937c(), scale, shape, inverseCumAccuracy);
}
 
Example #22
Source File: TriangularDistribution.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Creates a triangular real distribution using the given lower limit,
 * upper limit, and mode.
 *
 * @param a Lower limit of this distribution (inclusive).
 * @param b Upper limit of this distribution (inclusive).
 * @param c Mode of this distribution.
 * @throws NumberIsTooLargeException if {@code a >= b} or if {@code c > b}.
 * @throws NumberIsTooSmallException if {@code c < a}.
 */
public TriangularDistribution(double a, double c, double b)
    throws NumberIsTooLargeException, NumberIsTooSmallException {
    this(new Well19937c(), a, c, b);
}
 
Example #23
Source File: LogisticDistribution.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Build a new instance.
 * <p>
 * <b>Note:</b> this constructor will implicitly create an instance of
 * {@link Well19937c} as random generator to be used for sampling only (see
 * {@link #sample()} and {@link #sample(int)}). In case no sampling is
 * needed for the created distribution, it is advised to pass {@code null}
 * as random generator via the appropriate constructors to avoid the
 * additional initialisation overhead.
 *
 * @param mu location parameter
 * @param s scale parameter (must be positive)
 * @throws NotStrictlyPositiveException if {@code beta <= 0}
 */
public LogisticDistribution(double mu, double s) {
    this(new Well19937c(), mu, s);
}
 
Example #24
Source File: ParetoDistribution.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Create a Pareto distribution using the specified scale, shape and
 * inverse cumulative distribution accuracy.
 *
 * @param scale the scale parameter of this distribution
 * @param shape the shape parameter of this distribution
 * @param inverseCumAccuracy Inverse cumulative probability accuracy.
 * @throws NotStrictlyPositiveException if {@code scale <= 0} or {@code shape <= 0}.
 */
public ParetoDistribution(double scale, double shape, double inverseCumAccuracy)
    throws NotStrictlyPositiveException {
    this(new Well19937c(), scale, shape, inverseCumAccuracy);
}
 
Example #25
Source File: BinomialDistribution.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Create a binomial distribution with the given number of trials and
 * probability of success.
 *
 * @param trials Number of trials.
 * @param p Probability of success.
 * @throws NotPositiveException if {@code trials < 0}.
 * @throws OutOfRangeException if {@code p < 0} or {@code p > 1}.
 */
public BinomialDistribution(int trials, double p) {
    this(new Well19937c(), trials, p);
}
 
Example #26
Source File: Math_2_HypergeometricDistribution_s.java    From coming with MIT License 2 votes vote down vote up
/**
 * Construct a new hypergeometric distribution with the specified population
 * size, number of successes in the population, and sample size.
 *
 * @param populationSize Population size.
 * @param numberOfSuccesses Number of successes in the population.
 * @param sampleSize Sample size.
 * @throws NotPositiveException if {@code numberOfSuccesses < 0}.
 * @throws NotStrictlyPositiveException if {@code populationSize <= 0}.
 * @throws NumberIsTooLargeException if {@code numberOfSuccesses > populationSize},
 * or {@code sampleSize > populationSize}.
 */
public HypergeometricDistribution(int populationSize, int numberOfSuccesses, int sampleSize)
throws NotPositiveException, NotStrictlyPositiveException, NumberIsTooLargeException {
    this(new Well19937c(), populationSize, numberOfSuccesses, sampleSize);
}
 
Example #27
Source File: UniformRealDistribution.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Create a uniform real distribution using the given lower and upper
 * bounds.
 * <p>
 * <b>Note:</b> this constructor will implicitly create an instance of
 * {@link Well19937c} as random generator to be used for sampling only (see
 * {@link #sample()} and {@link #sample(int)}). In case no sampling is
 * needed for the created distribution, it is advised to pass {@code null}
 * as random generator via the appropriate constructors to avoid the
 * additional initialisation overhead.
 *
 * @param lower Lower bound of this distribution (inclusive).
 * @param upper Upper bound of this distribution (exclusive).
 * @throws NumberIsTooLargeException if {@code lower >= upper}.
 */
public UniformRealDistribution(double lower, double upper)
    throws NumberIsTooLargeException {
    this(new Well19937c(), lower, upper);
}
 
Example #28
Source File: Math_8_DiscreteDistribution_s.java    From coming with MIT License 2 votes vote down vote up
/**
 * Create a discrete distribution using the given probability mass function
 * definition.
 *
 * @param samples definition of probability mass function in the format of
 * list of pairs.
 * @throws NotPositiveException if probability of at least one value is
 * negative.
 * @throws MathArithmeticException if the probabilities sum to zero.
 * @throws MathIllegalArgumentException if probability of at least one value
 * is infinite.
 */
public DiscreteDistribution(final List<Pair<T, Double>> samples)
    throws NotPositiveException, MathArithmeticException, MathIllegalArgumentException {
    this(new Well19937c(), samples);
}
 
Example #29
Source File: Math_8_DiscreteDistribution_t.java    From coming with MIT License 2 votes vote down vote up
/**
 * Create a discrete distribution using the given probability mass function
 * definition.
 *
 * @param samples definition of probability mass function in the format of
 * list of pairs.
 * @throws NotPositiveException if probability of at least one value is
 * negative.
 * @throws MathArithmeticException if the probabilities sum to zero.
 * @throws MathIllegalArgumentException if probability of at least one value
 * is infinite.
 */
public DiscreteDistribution(final List<Pair<T, Double>> samples)
    throws NotPositiveException, MathArithmeticException, MathIllegalArgumentException {
    this(new Well19937c(), samples);
}
 
Example #30
Source File: TriangularDistribution.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Creates a triangular real distribution using the given lower limit,
 * upper limit, and mode.
 *
 * @param a Lower limit of this distribution (inclusive).
 * @param b Upper limit of this distribution (inclusive).
 * @param c Mode of this distribution.
 * @throws NumberIsTooLargeException if {@code a >= b} or if {@code c > b}.
 * @throws NumberIsTooSmallException if {@code c < a}.
 */
public TriangularDistribution(double a, double c, double b)
    throws NumberIsTooLargeException, NumberIsTooSmallException {
    this(new Well19937c(), a, c, b);
}