/** * Generates a random value sampled from this distribution. The default * implementation uses the * <a href="http://en.wikipedia.org/wiki/Inverse_transform_sampling"> inversion method.</a> * * @return random value * @since 2.2 * @throws MathException if an error occurs generating the random value */ public double sample() throws MathException { return randomData.nextInversionDeviate(this); }
/** * Generates a random value sampled from this distribution. The default * implementation uses the * <a href="http://en.wikipedia.org/wiki/Inverse_transform_sampling"> inversion method.</a> * * @return random value * @since 2.2 * @throws MathException if an error occurs generating the random value */ public int sample() throws MathException { return randomData.nextInversionDeviate(this); }
/** * Generates a random value from the {@link FDistributionImpl F Distribution}. * This implementation uses {@link #nextInversionDeviate(ContinuousDistribution) inversion} * to generate random values. * * @param numeratorDf the numerator degrees of freedom of the F distribution * @param denominatorDf the denominator degrees of freedom of the F distribution * @return random value sampled from the F(numeratorDf, denominatorDf) distribution * @throws MathException if an error occurs generating the random value * @since 2.2 */ public double nextF(double numeratorDf, double denominatorDf) throws MathException { return nextInversionDeviate(new FDistributionImpl(numeratorDf, denominatorDf)); }
/** * Generates a random value from the {@link ChiSquaredDistributionImpl ChiSquare Distribution}. * This implementation uses {@link #nextInversionDeviate(ContinuousDistribution) inversion} * to generate random values. * * @param df the degrees of freedom of the ChiSquare distribution * @return random value sampled from the ChiSquare(df) distribution * @throws MathException if an error occurs generating the random value * @since 2.2 */ public double nextChiSquare(double df) throws MathException { return nextInversionDeviate(new ChiSquaredDistributionImpl(df)); }
/** * Generates a random value from the {@link BetaDistributionImpl Beta Distribution}. * This implementation uses {@link #nextInversionDeviate(ContinuousDistribution) inversion} * to generate random values. * * @param alpha first distribution shape parameter * @param beta second distribution shape parameter * @return random value sampled from the beta(alpha, beta) distribution * @throws MathException if an error occurs generating the random value * @since 2.2 */ public double nextBeta(double alpha, double beta) throws MathException { return nextInversionDeviate(new BetaDistributionImpl(alpha, beta)); }
/** * Generates a random value from the {@link BinomialDistributionImpl Binomial Distribution}. * This implementation uses {@link #nextInversionDeviate(ContinuousDistribution) inversion} * to generate random values. * * @param numberOfTrials number of trials of the Binomial distribution * @param probabilityOfSuccess probability of success of the Binomial distribution * @return random value sampled from the Binomial(numberOfTrials, probabilityOfSuccess) distribution * @throws MathException if an error occurs generating the random value * @since 2.2 */ public int nextBinomial(int numberOfTrials, double probabilityOfSuccess) throws MathException { return nextInversionDeviate(new BinomialDistributionImpl(numberOfTrials, probabilityOfSuccess)); }
/** * Generates a random value from the {@link HypergeometricDistributionImpl Hypergeometric Distribution}. * This implementation uses {@link #nextInversionDeviate(IntegerDistribution) inversion} * to generate random values. * * @param populationSize the population size of the Hypergeometric distribution * @param numberOfSuccesses number of successes in the population of the Hypergeometric distribution * @param sampleSize the sample size of the Hypergeometric distribution * @return random value sampled from the Hypergeometric(numberOfSuccesses, sampleSize) distribution * @throws MathException if an error occurs generating the random value * @since 2.2 */ public int nextHypergeometric(int populationSize, int numberOfSuccesses, int sampleSize) throws MathException { return nextInversionDeviate(new HypergeometricDistributionImpl(populationSize, numberOfSuccesses, sampleSize)); }
/** * Generates a random value from the {@link TDistributionImpl T Distribution}. * This implementation uses {@link #nextInversionDeviate(ContinuousDistribution) inversion} * to generate random values. * * @param df the degrees of freedom of the T distribution * @return random value from the T(df) distribution * @throws MathException if an error occurs generating the random value * @since 2.2 */ public double nextT(double df) throws MathException { return nextInversionDeviate(new TDistributionImpl(df)); }
/** * Generates a random value from the {@link CauchyDistributionImpl Cauchy Distribution}. * This implementation uses {@link #nextInversionDeviate(ContinuousDistribution) inversion} * to generate random values. * * @param median the median of the Cauchy distribution * @param scale the scale parameter of the Cauchy distribution * @return random value sampled from the Cauchy(median, scale) distribution * @throws MathException if an error occurs generating the random value * @since 2.2 */ public double nextCauchy(double median, double scale) throws MathException { return nextInversionDeviate(new CauchyDistributionImpl(median, scale)); }
/** * Generates a random value from the {@link GammaDistributionImpl Gamma Distribution}. * This implementation uses {@link #nextInversionDeviate(ContinuousDistribution) inversion} * to generate random values. * * @param shape the median of the Gamma distribution * @param scale the scale parameter of the Gamma distribution * @return random value sampled from the Gamma(shape, scale) distribution * @throws MathException if an error occurs generating the random value * @since 2.2 */ public double nextGamma(double shape, double scale) throws MathException { return nextInversionDeviate(new GammaDistributionImpl(shape, scale)); }
/** * Generates a random value from the {@link PascalDistributionImpl Pascal Distribution}. * This implementation uses {@link #nextInversionDeviate(IntegerDistribution) inversion} * to generate random values. * * @param r the number of successes of the Pascal distribution * @param p the probability of success of the Pascal distribution * @return random value sampled from the Pascal(r, p) distribution * @throws MathException if an error occurs generating the random value * @since 2.2 */ public int nextPascal(int r, double p) throws MathException { return nextInversionDeviate(new PascalDistributionImpl(r, p)); }
/** * Generates a random value from the {@link WeibullDistributionImpl Weibull Distribution}. * This implementation uses {@link #nextInversionDeviate(ContinuousDistribution) inversion} * to generate random values. * * @param shape the shape parameter of the Weibull distribution * @param scale the scale parameter of the Weibull distribution * @return random value sampled from the Weibull(shape, size) distribution * @throws MathException if an error occurs generating the random value * @since 2.2 */ public double nextWeibull(double shape, double scale) throws MathException { return nextInversionDeviate(new WeibullDistributionImpl(shape, scale)); }
/** * Generates a random value from the {@link ZipfDistributionImpl Zipf Distribution}. * This implementation uses {@link #nextInversionDeviate(IntegerDistribution) inversion} * to generate random values. * * @param numberOfElements the number of elements of the ZipfDistribution * @param exponent the exponent of the ZipfDistribution * @return random value sampled from the Zipf(numberOfElements, exponent) distribution * @throws MathException if an error occurs generating the random value * @since 2.2 */ public int nextZipf(int numberOfElements, double exponent) throws MathException { return nextInversionDeviate(new ZipfDistributionImpl(numberOfElements, exponent)); }