/** * <p>Generates a random value from the * {@link org.apache.commons.math3.distribution.GammaDistribution Gamma Distribution}.</p> * * <p>This implementation uses the following algorithms: </p> * * <p>For 0 < shape < 1: <br/> * Ahrens, J. H. and Dieter, U., <i>Computer methods for * sampling from gamma, beta, Poisson and binomial distributions.</i> * Computing, 12, 223-246, 1974.</p> * * <p>For shape >= 1: <br/> * Marsaglia and Tsang, <i>A Simple Method for Generating * Gamma Variables.</i> ACM Transactions on Mathematical Software, * Volume 26 Issue 3, September, 2000.</p> * * @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 NotStrictlyPositiveException if {@code shape <= 0} or * {@code scale <= 0}. * @since 2.2 */ public double nextGamma(double shape, double scale) throws NotStrictlyPositiveException { return delegate.nextGamma(shape, scale); }
/** * <p>Generates a random value from the * {@link org.apache.commons.math3.distribution.GammaDistribution Gamma Distribution}.</p> * * <p>This implementation uses the following algorithms: </p> * * <p>For 0 < shape < 1: <br/> * Ahrens, J. H. and Dieter, U., <i>Computer methods for * sampling from gamma, beta, Poisson and binomial distributions.</i> * Computing, 12, 223-246, 1974.</p> * * <p>For shape >= 1: <br/> * Marsaglia and Tsang, <i>A Simple Method for Generating * Gamma Variables.</i> ACM Transactions on Mathematical Software, * Volume 26 Issue 3, September, 2000.</p> * * @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 NotStrictlyPositiveException if {@code shape <= 0} or * {@code scale <= 0}. * @since 2.2 */ public double nextGamma(double shape, double scale) throws NotStrictlyPositiveException { return delegate.nextGamma(shape, scale); }
/** * <p>Generates a random value from the * {@link org.apache.commons.math3.distribution.GammaDistribution Gamma Distribution}.</p> * * <p>This implementation uses the following algorithms: </p> * * <p>For 0 < shape < 1: <br/> * Ahrens, J. H. and Dieter, U., <i>Computer methods for * sampling from gamma, beta, Poisson and binomial distributions.</i> * Computing, 12, 223-246, 1974.</p> * * <p>For shape >= 1: <br/> * Marsaglia and Tsang, <i>A Simple Method for Generating * Gamma Variables.</i> ACM Transactions on Mathematical Software, * Volume 26 Issue 3, September, 2000.</p> * * @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 NotStrictlyPositiveException if {@code shape <= 0} or * {@code scale <= 0}. * @since 2.2 */ public double nextGamma(double shape, double scale) throws NotStrictlyPositiveException { return delegate.nextGamma(shape, scale); }
/** * Replaces each pixel value with a sample from a Gamma distribution with shape equal to the original pixel value and scale equal to the gain parameter. */ FloatProcessor sampleGamma(FloatProcessor fp, double gain){ for(int i = 0; i < fp.getPixelCount(); i ++){ double value = fp.getf(i); value = rand.nextGamma(value + 1e-10, gain); fp.setf(i, (float)value); } return fp; }