C#: Numerical algorithm to generate numbers from Binomial distribution

前端 未结 3 490
名媛妹妹
名媛妹妹 2021-01-17 22:59

I need to generate random numbers from Binomial(n,p) distribution.

A Binomial(n,p) random variable is sum of n uniform variables which take 1 with probability p. In

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-17 23:49

    If you are willing to pay, then take a look at NMath by Centerspace.

    Otherwise, the C code used by the Stats program R is here, and should be straightforward to port to C#.

    EDIT: There are details (inc. code) on creating a method for this on p178 of Practical Numerical Methods with C# by Jack Xu.

    ANOTHER EDIT: A free C# library that does what you want.

提交回复
热议问题