在正态分布的*部分*上进行分布的算法

发布于 2024-08-15 20:32:10 字数 285 浏览 3 评论 0原文

是否有一种单遍算法可以生成分布在正态(高斯)分布的部分上的数字?

我想指定一个基值(分布的中心)、标准差以及最小值和最大值。

例如,我可能希望所有值分布在 -0.5 和 +1 标准差之间,其比例与正态分布中的比例相同(显然增加是为了考虑到缺失的尾部)。

显然,可以使用循环,并且只有在生成的数字介于最小值和最大值之间时才退出,但如果最小值/最大值太接近或沿尾部太远,则可能会持续很长时间。

我假设一种具有高斯随机数函数的语言(我使用的是 Java,但几乎可以读取任何内容)。

Is there a single pass algorithm that can produce numbers distributed over part of a normal (Gaussian) distribution?

I want to specify a base value (the center of the distribution), a standard deviation, and a min and max values.

For example I might want all values to be distributed between -0.5 and +1 standard deviations in the same ratio as would be found in a normal distribution (obviously increased to take into account the missing tails).

Obviously one can use a loop and only exit if the generated number was between the minimum and maximum, but that could go on for a long time if min/max are too close together or too far out along a tail.

I'm assuming a language with a Gaussian random number function (I'm using Java, but can read almost anything).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

哀由 2024-08-22 20:32:10

您可以计算给定高斯在最小和最大兴趣点处的 erf ,生成随机数这两个值之间的数字(统一),并取逆erf

我知道 Apache 库在 Java 中有一个 erf 函数,请参阅 这里,但我不确定在哪里指出 erf 的逆(当然,最坏的情况,你可以计算后者与牛顿-拉夫森)。

(我在这里找到了一种逆 erf 算法 ,使用 Java 实现,但不能保证其质量)。

You can compute erf for the given Gaussian at the minimum and maximum points of interest, generate the random number (uniformly) between those two values, and take inverse erf.

I know the Apache library has an erf function in Java, see here, but I'm not sure where to point you for an inverse of erf (worst case, of course, you could calculate the latter with Newton-Raphson).

(I found an algorithm for inverse erf here, with Java implementation, but can't vouch for its quality).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文