Package org.apache.commons.math.exception

Examples of org.apache.commons.math.exception.NotStrictlyPositiveException


     * @return the random string.
     * @throws NotStrictlyPositiveException if {@code len <= 0}.
     */
    public String nextHexString(int len) {
        if (len <= 0) {
            throw new NotStrictlyPositiveException(LocalizedFormats.LENGTH, len);
        }

        // Get a random number generator
        RandomGenerator ran = getRan();

View Full Code Here


     * @return the random string
     * @throws NotStrictlyPositiveException if {@code len <= 0}.
     */
    public String nextSecureHexString(int len) {
        if (len <= 0) {
            throw new NotStrictlyPositiveException(LocalizedFormats.LENGTH, len);
        }

        // Get SecureRandom and setup Digest provider
        SecureRandom secRan = getSecRan();
        MessageDigest alg = null;
View Full Code Here

     * @return the random Poisson value.
     * @throws NotStrictlyPositiveException if {@code mean <= 0}.
     */
    public long nextPoisson(double mean) {
        if (mean <= 0) {
            throw new NotStrictlyPositiveException(LocalizedFormats.MEAN, mean);
        }

        final RandomGenerator generator = getRan();

        final double pivot = 40.0d;
View Full Code Here

     * @return the random Normal value
     * @throws NotStrictlyPositiveException if {@code sigma <= 0}.
     */
    public double nextGaussian(double mu, double sigma) {
        if (sigma <= 0) {
            throw new NotStrictlyPositiveException(LocalizedFormats.STANDARD_DEVIATION, sigma);
        }
        return sigma * getRan().nextGaussian() + mu;
    }
View Full Code Here

     * @return the random Exponential value
     * @throws NotStrictlyPositiveException if {@code mean <= 0}.
     */
    public double nextExponential(double mean) {
        if (mean <= 0.0) {
            throw new NotStrictlyPositiveException(LocalizedFormats.MEAN, mean);
        }
        final RandomGenerator generator = getRan();
        double unif = generator.nextDouble();
        while (unif == 0.0d) {
            unif = generator.nextDouble();
View Full Code Here

        if (k > n) {
            throw new NumberIsTooLargeException(LocalizedFormats.PERMUTATION_EXCEEDS_N,
                                                k, n, true);
        }
        if (k == 0) {
            throw new NotStrictlyPositiveException(LocalizedFormats.PERMUTATION_SIZE,
                                                   k);
        }

        int[] index = getNatural(n);
        shuffle(index, n - k);
View Full Code Here

        if (k > len) {
            throw new NumberIsTooLargeException(LocalizedFormats.SAMPLE_SIZE_EXCEEDS_COLLECTION_SIZE,
                                                k, len, true);
        }
        if (k <= 0) {
            throw new NotStrictlyPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES, k);
        }

        Object[] objects = c.toArray();
        int[] index = nextPermutation(len, k);
        Object[] result = new Object[k];
View Full Code Here

     * value between 0 (inclusive) and n (exclusive).
     * @throws NotStrictlyPositiveException if {@code n <= 0}.
     */
    public int nextInt(int n) {
        if (n <= 0 ) {
            throw new NotStrictlyPositiveException(n);
        }
        int result = (int) (nextDouble() * n);
        return result < n ? result : n - 1;
    }
View Full Code Here

            tS *= size[i];
        }
        uniCounterOffset[last] = 0;

        if (tS <= 0) {
            throw new NotStrictlyPositiveException(tS);
        }

        totalSize = tS;
    }
View Full Code Here

    /** {@inheritDoc} */
    public int nextInt(int n) throws IllegalArgumentException {

        if (n < 1) {
            throw new NotStrictlyPositiveException(n);
        }

        // find bit mask for n
        int mask = n;
        mask |= mask >> 1;
View Full Code Here

TOP

Related Classes of org.apache.commons.math.exception.NotStrictlyPositiveException

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.