Java:概率分布支持

Java: Probability distribution support

我需要在我的 java 程序中从一些常见的概率分布(正态、二项式、伽马等)中实施随机抽样。我找到了 Random.nextGaussian() 并且只是想知道是否有任何其他内置支持除正常之外的发行版?或者我唯一的选择是第三方库还是 DIY?

您会查看 java.lang.math,并且来自 docs

The class Math contains methods for performing basic numeric operations such as the elementary exponential, logarithm, square root, and trigonometric functions.

简而言之,没有。对于高斯分布以外的分布,您将不得不寻找其他地方。

第三方库方面,Apache Commons (AbstractRealDistribution) is probably your best bet. But I’ve also had success with Colt

至于 DIY,一个简单的 google 搜索应该可以做到,例如Gamma, Binomial