List of usage examples for org.apache.commons.math3.exception NotStrictlyPositiveException NotStrictlyPositiveException
public NotStrictlyPositiveException(Localizable specific, Number value)
From source file:experiment.PascalDistribution_bug.java
/** * Create a Pascal distribution with the given number of successes and * probability of success.//w w w . j av a 2 s . c om * * @param rng Random number generator. * @param r Number of successes. * @param p Probability of success. * @throws NotStrictlyPositiveException if the number of successes is not positive * @throws OutOfRangeException if the probability of success is not in the * range {@code [0, 1]}. * @since 3.1 */ public PascalDistribution_bug(RandomGenerator rng, int r, double p, int id) throws NotStrictlyPositiveException, OutOfRangeException { super(rng); if (r <= 0) { throw new NotStrictlyPositiveException(LocalizedFormats.NUMBER_OF_SUCCESSES, r); } if (p < 0 || p > 1) { throw new OutOfRangeException(p, 0, 1); } numberOfSuccesses = r; probabilityOfSuccess = p; }
From source file:gmc_hdfs.distribution.ParetoDistribution.java
/** * Creates a Pareto distribution.// ww w . j av a2 s. co m * * @param rng Random number generator. * @param scale Scale parameter of this distribution. * @param shape Shape parameter of this distribution. * @param inverseCumAccuracy Inverse cumulative probability accuracy. * @throws NotStrictlyPositiveException if {@code scale <= 0} or {@code shape <= 0}. */ public ParetoDistribution(RandomGenerator rng, double scale, double shape, double inverseCumAccuracy) throws NotStrictlyPositiveException { super(rng); if (scale <= 0) { throw new NotStrictlyPositiveException(LocalizedFormats.SCALE, scale); } if (shape <= 0) { throw new NotStrictlyPositiveException(LocalizedFormats.SHAPE, shape); } this.scale = scale; this.shape = shape; this.solverAbsoluteAccuracy = inverseCumAccuracy; }
From source file:org.nd4j.linalg.api.rng.distribution.BaseDistribution.java
/** * {@inheritDoc}/*from w w w. ja v a 2 s. c o m*/ * <p/> * The default implementation generates the sample by calling * {@link #sample()} in a loop. */ @Override 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; }
From source file:org.nd4j.linalg.api.rng.distribution.impl.LogNormalDistribution.java
/** * Creates a normal distribution./*from w ww . ja va 2 s . c om*/ * * @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; }
From source file:org.nd4j.linalg.api.rng.distribution.impl.NormalDistribution.java
/** * Creates a normal distribution.//from ww w . j a v a 2 s .co m * * @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; }
From source file:org.nd4j.linalg.api.rng.distribution.impl.TruncatedNormalDistribution.java
/** * Creates a normal distribution./*from www .j a v a 2s . co m*/ * * @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; }
From source file:org.nd4j.linalg.jcublas.rng.distribution.NormalDistribution.java
/** * Creates a normal distribution.// w w w .j a v a 2 s.com * * @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((JcudaRandom) rng); if (sd <= 0) { throw new NotStrictlyPositiveException(LocalizedFormats.STANDARD_DEVIATION, sd); } this.mean = mean; standardDeviation = sd; solverAbsoluteAccuracy = inverseCumAccuracy; }
From source file:statalign.utils.GammaDistribution.java
/** * Creates a Gamma distribution.//from ww w. j av a 2s . co m * * @param rng Random number generator. * @param shape the shape parameter * @param scale the scale parameter * @param inverseCumAccuracy the maximum absolute error in inverse * cumulative probability estimates (defaults to * {@link #DEFAULT_INVERSE_ABSOLUTE_ACCURACY}). * @throws NotStrictlyPositiveException if {@code shape <= 0} or * {@code scale <= 0}. * @since 3.1 */ public GammaDistribution(RandomGenerator rng, double shape, double scale, double inverseCumAccuracy) throws NotStrictlyPositiveException { super(rng); if (shape <= 0) { throw new NotStrictlyPositiveException(LocalizedFormats.SHAPE, shape); } if (scale <= 0) { throw new NotStrictlyPositiveException(LocalizedFormats.SCALE, scale); } this.shape = shape; this.scale = scale; this.solverAbsoluteAccuracy = inverseCumAccuracy; this.shiftedShape = shape + Gamma.LANCZOS_G + 0.5; final double aux = FastMath.E / (2.0 * FastMath.PI * shiftedShape); this.densityPrefactor2 = shape * FastMath.sqrt(aux) / Gamma.lanczos(shape); this.densityPrefactor1 = this.densityPrefactor2 / scale * FastMath.pow(shiftedShape, -shape) * FastMath.exp(shape + Gamma.LANCZOS_G); this.minY = shape + Gamma.LANCZOS_G - FastMath.log(Double.MAX_VALUE); this.maxLogY = FastMath.log(Double.MAX_VALUE) / (shape - 1.0); }
From source file:statalign.utils.NormalDistribution.java
/** * Creates a normal distribution.//from w w w .ja v a 2 s . c o m * * @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(RandomGenerator 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; }