/** * @param max Allowed number of evalutations. * @throws NotStrictlyPositiveException if {@code max <= 0}. */ public MaxEval(int max) { if (max <= 0) { throw new NotStrictlyPositiveException(max); } maxEval = max; }
/** * @param n Number of observations * @throws NotStrictlyPositiveException if {@code n <= 0} */ public KolmogorovSmirnovDistribution(int n) throws NotStrictlyPositiveException { if (n <= 0) { throw new NotStrictlyPositiveException(LocalizedFormats.NOT_POSITIVE_NUMBER_OF_SAMPLES, n); } this.n = n; }
/** * @param max Allowed number of iterations. * @throws NotStrictlyPositiveException if {@code max <= 0}. */ public MaxIter(int max) { if (max <= 0) { throw new NotStrictlyPositiveException(max); } maxIter = max; }
/** * @param size Population size. * @throws NotStrictlyPositiveException if {@code size <= 0}. */ public PopulationSize(int size) throws NotStrictlyPositiveException { if (size <= 0) { throw new NotStrictlyPositiveException(size); } lambda = size; }
/** * @param size Population size. * @throws NotStrictlyPositiveException if {@code size <= 0}. */ public PopulationSize(int size) throws NotStrictlyPositiveException { if (size <= 0) { throw new NotStrictlyPositiveException(size); } lambda = size; }
/** * Creates a new {@link NPointCrossover} policy using the given number of points. * <p> * <b>Note</b>: the number of crossover points must be < <code>chromosome length - 1</code>. * This condition can only be checked at runtime, as the chromosome length is not known in advance. * * @param crossoverPoints the number of crossover points * @throws NotStrictlyPositiveException if the number of {@code crossoverPoints} is not strictly positive */ public NPointCrossover(final int crossoverPoints) throws NotStrictlyPositiveException { if (crossoverPoints <= 0) { throw new NotStrictlyPositiveException(crossoverPoints); } this.crossoverPoints = crossoverPoints; }
/** * Build a new instance. * * @param rng Random number generator * @param mu location parameter * @param s scale parameter (must be positive) * @throws NotStrictlyPositiveException if {@code beta <= 0} */ public LogisticDistribution(RandomGenerator rng, double mu, double s) { super(rng); if (s <= 0.0) { throw new NotStrictlyPositiveException(LocalizedFormats.NOT_POSITIVE_SCALE, s); } this.mu = mu; this.s = s; }
/** * Build a new instance. * * @param rng Random number generator * @param mu location parameter * @param beta scale parameter (must be positive) * @throws NotStrictlyPositiveException if {@code beta <= 0} */ public GumbelDistribution(RandomGenerator rng, double mu, double beta) { super(rng); if (beta <= 0) { throw new NotStrictlyPositiveException(LocalizedFormats.SCALE, beta); } this.beta = beta; this.mu = mu; }
/** * Check that all entries of the input array are strictly positive. * * @param in Array to be tested * @throws NotStrictlyPositiveException if any entries of the array are not * strictly positive. * @since 3.1 */ public static void checkPositive(final double[] in) throws NotStrictlyPositiveException { for (int i = 0; i < in.length; i++) { if (in[i] <= 0) { throw new NotStrictlyPositiveException(in[i]); } } }
/** * Build a new instance. * * @param rng Random number generator * @param mu location parameter * @param beta scale parameter (must be positive) * @throws NotStrictlyPositiveException if {@code beta <= 0} */ public LaplaceDistribution(RandomGenerator rng, double mu, double beta) { super(rng); if (beta <= 0.0) { throw new NotStrictlyPositiveException(LocalizedFormats.NOT_POSITIVE_SCALE, beta); } this.mu = mu; this.beta = beta; }
/** * Create a new RealMatrix with the supplied row and column dimensions. * * @param rowDimension the number of rows in the new matrix * @param columnDimension the number of columns in the new matrix * @throws NotStrictlyPositiveException if row or column dimension is not positive */ protected AbstractRealMatrix(final int rowDimension, final int columnDimension) throws NotStrictlyPositiveException { if (rowDimension < 1) { throw new NotStrictlyPositiveException(rowDimension); } if (columnDimension < 1) { throw new NotStrictlyPositiveException(columnDimension); } }
/** {@inheritDoc} */ public int nextInt(int n) { if (n <= 0) { throw new NotStrictlyPositiveException(n); } return rng.nextInt(n); }
/** {@inheritDoc} */ public double[][] sample(final int sampleSize) { if (sampleSize <= 0) { throw new NotStrictlyPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES, sampleSize); } final double[][] out = new double[sampleSize][dimension]; for (int i = 0; i < sampleSize; i++) { out[i] = sample(); } return out; } }
/** * Private constructor to allow lazy initialisation of the RNG contained * in the {@link #randomData} instance variable. * * @param binCount number of bins. Must be strictly positive. * @param randomData Random data generator. * @throws NotStrictlyPositiveException if {@code binCount <= 0}. */ private EmpiricalDistribution(int binCount, RandomDataGenerator randomData) { super(randomData.getRandomGenerator()); if (binCount <= 0) { throw new NotStrictlyPositiveException(binCount); } this.binCount = binCount; this.randomData = randomData; binStats = new ArrayList<SummaryStatistics>(); }
/** * {@inheritDoc} * <p/> * The default implementation generates the sample by calling * {@link #sample()} in a loop. */ @Override public double[] sample(long sampleSize) { if (sampleSize <= 0) { throw new NotStrictlyPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES, sampleSize); } // FIXME: int cast double[] out = new double[(int) sampleSize]; for (int i = 0; i < sampleSize; i++) { out[i] = sample(); } return out; }
/** * {@inheritDoc} * * The default implementation generates the sample by calling * {@link #sample()} in a loop. */ public double[] sample(int sampleSize) { if (sampleSize <= 0) { throw new NotStrictlyPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES, sampleSize); } double[] out = new double[sampleSize]; for (int i = 0; i < sampleSize; i++) { out[i] = sample(); } return out; }
/** * {@inheritDoc} * * The default implementation generates the sample by calling * {@link #sample()} in a loop. */ public int[] sample(int sampleSize) { if (sampleSize <= 0) { throw new NotStrictlyPositiveException( LocalizedFormats.NUMBER_OF_SAMPLES, sampleSize); } int[] out = new int[sampleSize]; for (int i = 0; i < sampleSize; i++) { out[i] = sample(); } return out; }
/** * Create a bracketing interval finder. * * @param growLimit Expanding factor. * @param maxEvaluations Maximum number of evaluations allowed for finding * a bracketing interval. */ public BracketFinder(double growLimit, int maxEvaluations) { if (growLimit <= 0) { throw new NotStrictlyPositiveException(growLimit); } if (maxEvaluations <= 0) { throw new NotStrictlyPositiveException(maxEvaluations); } this.growLimit = growLimit; evaluations = IntegerSequence.Incrementor.create().withMaximalCount(maxEvaluations); }
/** {@inheritDoc} */ public double nextGaussian(double mu, double sigma) throws NotStrictlyPositiveException { if (sigma <= 0) { throw new NotStrictlyPositiveException(LocalizedFormats.STANDARD_DEVIATION, sigma); } return sigma * getRandomGenerator().nextGaussian() + mu; }
/** * Performs multiple increments. * * @param nTimes Number of increments. * @throws MaxCountExceededException at counter exhaustion. * @throws NotStrictlyPositiveException if {@code nTimes <= 0}. * * @see #increment() */ public void increment(int nTimes) throws MaxCountExceededException { if (nTimes <= 0) { throw new NotStrictlyPositiveException(nTimes); } if (!canIncrement(0)) { maxCountCallback.trigger(maximalCount); } count += nTimes * increment; }