/** * @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); } }
/** * Creates a normal distribution. * * @param rng Random number generator. * @param mean Mean for this distribution. * @param sd Standard deviation for this distribution. * @param inverseCumAccuracy Inverse cumulative probability accuracy. * @throws NotStrictlyPositiveException if {@code sd <= 0}. * @since 3.1 */ public NormalDistribution(Random rng, double mean, double sd, double inverseCumAccuracy) throws NotStrictlyPositiveException { super(rng); if (sd <= 0) { throw new NotStrictlyPositiveException(LocalizedFormats.STANDARD_DEVIATION, sd); } this.mean = mean; standardDeviation = sd; solverAbsoluteAccuracy = inverseCumAccuracy; }
/** * Creates a normal distribution. * * @param rng Random number generator. * @param mean Mean for this distribution. * @param sd Standard deviation for this distribution. * @param inverseCumAccuracy Inverse cumulative probability accuracy. * @throws NotStrictlyPositiveException if {@code sd <= 0}. * @since 3.1 */ public TruncatedNormalDistribution(Random rng, double mean, double sd, double inverseCumAccuracy) throws NotStrictlyPositiveException { super(rng); if (sd <= 0) { throw new NotStrictlyPositiveException(LocalizedFormats.STANDARD_DEVIATION, sd); } this.mean = mean; standardDeviation = sd; solverAbsoluteAccuracy = inverseCumAccuracy; }
/** * Creates a normal distribution. * * @param rng Random number generator. * @param mean Mean for this distribution. * @param sd Standard deviation for this distribution. * @param inverseCumAccuracy Inverse cumulative probability accuracy. * @throws NotStrictlyPositiveException if {@code sd <= 0}. * @since 3.1 */ public LogNormalDistribution(Random rng, double mean, double sd, double inverseCumAccuracy) throws NotStrictlyPositiveException { super(rng); if (sd <= 0) { throw new NotStrictlyPositiveException(LocalizedFormats.STANDARD_DEVIATION, sd); } this.mean = mean; standardDeviation = sd; solverAbsoluteAccuracy = inverseCumAccuracy; }
/** * Gaussian with given normalization factor, mean and standard deviation. * * @param norm Normalization factor. * @param mean Mean. * @param sigma Standard deviation. * @throws NotStrictlyPositiveException if {@code sigma <= 0}. */ public Gaussian(double norm, double mean, double sigma) throws NotStrictlyPositiveException { if (sigma <= 0) { throw new NotStrictlyPositiveException(sigma); } this.norm = norm; this.mean = mean; this.is = 1 / sigma; this.i2s2 = 0.5 * is * is; }
/** * Builds an instance with specified tolerance thresholds and * iteration count. * * In order to perform only relative checks, the absolute tolerance * must be set to a negative value. In order to perform only absolute * checks, the relative tolerance must be set to a negative value. * * @param relativeThreshold Relative tolerance threshold. * @param absoluteThreshold Absolute tolerance threshold. * @param maxIter Maximum iteration count. * @throws NotStrictlyPositiveException if {@code maxIter <= 0}. * * @since 3.1 */ public SimpleVectorValueChecker(final double relativeThreshold, final double absoluteThreshold, final int maxIter) { super(relativeThreshold, absoluteThreshold); if (maxIter <= 0) { throw new NotStrictlyPositiveException(maxIter); } maxIterationCount = maxIter; }
/** * Creates a Cauchy distribution. * * @param rng Random number generator. * @param median Median for this distribution. * @param scale Scale parameter for this distribution. * @param inverseCumAccuracy Maximum absolute error in inverse * cumulative probability estimates * (defaults to {@link #DEFAULT_INVERSE_ABSOLUTE_ACCURACY}). * @throws NotStrictlyPositiveException if {@code scale <= 0}. * @since 3.1 */ public CauchyDistribution(RandomGenerator rng, double median, double scale, double inverseCumAccuracy) { super(rng); if (scale <= 0) { throw new NotStrictlyPositiveException(LocalizedFormats.SCALE, scale); } this.scale = scale; this.median = median; solverAbsoluteAccuracy = inverseCumAccuracy; }
/** * Builds an instance with specified thresholds. * In order to perform only relative checks, the absolute tolerance * must be set to a negative value. In order to perform only absolute * checks, the relative tolerance must be set to a negative value. * * @param relativeThreshold Relative tolerance threshold. * @param absoluteThreshold Absolute tolerance threshold. * @param maxIter Maximum iteration count. * @throws NotStrictlyPositiveException if {@code maxIter <= 0}. * * @since 3.1 */ public SimplePointChecker(final double relativeThreshold, final double absoluteThreshold, final int maxIter) { super(relativeThreshold, absoluteThreshold); if (maxIter <= 0) { throw new NotStrictlyPositiveException(maxIter); } maxIterationCount = maxIter; }
/** * Builds an instance with specified thresholds. * In order to perform only relative checks, the absolute tolerance * must be set to a negative value. In order to perform only absolute * checks, the relative tolerance must be set to a negative value. * * @param relativeThreshold Relative tolerance threshold. * @param absoluteThreshold Absolute tolerance threshold. * @param maxIter Maximum iteration count. * @throws NotStrictlyPositiveException if {@code maxIter <= 0}. * * @since 3.1 */ public SimplePointChecker(final double relativeThreshold, final double absoluteThreshold, final int maxIter) { super(relativeThreshold, absoluteThreshold); if (maxIter <= 0) { throw new NotStrictlyPositiveException(maxIter); } maxIterationCount = maxIter; }
/** * Builds an instance with specified thresholds. * * In order to perform only relative checks, the absolute tolerance * must be set to a negative value. In order to perform only absolute * checks, the relative tolerance must be set to a negative value. * * @param relativeThreshold relative tolerance threshold * @param absoluteThreshold absolute tolerance threshold * @param maxIter Maximum iteration count. * @throws NotStrictlyPositiveException if {@code maxIter <= 0}. * * @since 3.1 */ public SimpleUnivariateValueChecker(final double relativeThreshold, final double absoluteThreshold, final int maxIter) { super(relativeThreshold, absoluteThreshold); if (maxIter <= 0) { throw new NotStrictlyPositiveException(maxIter); } maxIterationCount = maxIter; }