【发布时间】:2014-07-24 10:00:07
【问题描述】:
如何从 F# 中的指定正态分布中获取随机值?
我想要类似于 Python 的 x = numpy.random.normal(mean, standard_deviation),但在 F# 中。
【问题讨论】:
-
没有内置方法,但您可以很容易地实现 box-muller 变换 - en.wikipedia.org/wiki/Box%E2%80%93Muller_transform
如何从 F# 中的指定正态分布中获取随机值?
我想要类似于 Python 的 x = numpy.random.normal(mean, standard_deviation),但在 F# 中。
【问题讨论】:
例如,您可以使用 Math.NET Numerics 库。
open MathNet.Numerics.Distributions
let normalDist = new Normal(mean, stddev)
normalDist.Sample()
【讨论】: