从Java中的gamma分布生成随机值

时间:2014-09-17 07:44:39

标签: java random gamma-distribution

如何从Java中的gamma分布生成数字?

2 个答案:

答案 0 :(得分:2)

来自Apache Commons-Math软件包的GammaDistribution

double sample = new GammaDistribution(shape, scale).sample();

答案 1 :(得分:1)

Apache Commons Math 3.3 API有可能

GammaDistribution(double shape, double scale)
// Creates a new gamma distribution with specified values of the shape and scale parameters.
GammaDistribution(double shape, double scale, double inverseCumAccuracy)
// Creates a new gamma distribution with specified values of the shape and scale parameters.
GammaDistribution(RandomGenerator rng, double shape, double scale)
// Creates a Gamma distribution.
GammaDistribution(RandomGenerator rng, double shape, double scale, double inverseCumAccuracy)
// Creates a Gamma distribution.

参考:http://commons.apache.org/proper/commons-math/apidocs/org/apache/commons/math3/distribution/GammaDistribution.html