美文网首页
Generating Random Variables in V

Generating Random Variables in V

作者: 茱菁蔓 | 来源:发表于2017-01-09 10:37 被阅读0次

    Uniform distributiom Rnd()

    Public Function UniformRand() As Double

    UniformRand = Rnd()

    End Function

    或者 a到b之间随机整数

    Public Function Uniform( a As Double, b As Double ) As Double

    Uniform = Int( a + Rnd() * (b - a + 1) )

    End Function

    Normal Distribution

    Function Random_SNorm1() As Double

    Dim u1 As Double

    Dim u2 As Double

    u1 = Rnd()

    u2 = Rnd()

    Random_SNorm1 = Sqr(-2 * Log(u1)) * Cos(2 * 3.1415927 * u2)

    End Function

    相关文章

      网友评论

          本文标题:Generating Random Variables in V

          本文链接:https://www.haomeiwen.com/subject/ivvcbttx.html