我需要使用随机数来产生一个呈钟形曲线形状的统计平均值,以下是我的尝试:
Function slopedrand(max As Single, bias As Single) As Integer
Dim count As Single = 0
While count < bias
max = rand.NextDouble() * max
count += rand.NextDouble()
End While
Return rand.NextDouble() * max
End Function
Function bulgedrand(min As Single, max As Single, bulge As Single, bias As Single)
Dim negative = bulge - min
Dim positive = max - bulge
Dim nr = min + slopedrand(negative, bias)
Dim pr = max - slopedrand(positive, bias)
Return rand.NextDouble() * (pr - nr) + nr
End Function
然而,考虑到我不擅长数学,它只会产生像这样的东西:http://i.imgur.com/JDAW6kM.png,更像是一个突起...由于感觉我的头骨在煮沸,也许这里有人已经想出了如何实现我需要的内容,并会免去我进一步尝试思考的困境?(示例以vb.net为例,因为它很快可以原型化,但欢迎使用任何语言。)
double
”几乎不是一个解释)而删除问题。显然,这是在谈论您最近删除的问题。 - Pascal Cuoq