【问题标题】:Random numbers in the shape of a bell curve [duplicate]钟形曲线形状的随机数[重复]
【发布时间】:2015-10-30 16:11:47
【问题描述】:

我需要操纵随机来产生具有钟形曲线形状的统计平均值,这是我的尝试:

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 中给出,因为它可以快速原型化,但欢迎使用任何语言)

【问题讨论】:

  • 这是关于什么语言的?它看起来像 vb.net。
  • rand() + rand() 基本上不会给你一些接近贝尔曲线的东西吗?
  • 当您说“钟形曲线”时,您的意思是正态(高斯)分布吗?如果是这样,那么我可以让我的答案更具体。
  • 这是某种形式的视觉基础。
  • 我很确定是vb.net,vb6和vba不允许你在同一个“声明”中声明和定义。但 OP 可以确认...

标签: algorithm random


【解决方案1】:

钟形曲线可以用正态分布来近似,所以我想你可以在正态分布的公式中使用随机值并得到你需要的效果,比如这个答案:

drawing random number from a standard normal distribution using the standard rand() functions

也许对你有帮助?

【讨论】:

    【解决方案2】:

    “既定”的做法是在 [0, 1) 范围内绘制一个均匀分布的随机数,然后应用贝尔曲线分布的 quantile 函数。然后,这会为您提供一个与贝尔曲线具有相同分布的随机数。

    【讨论】: