Random number with specific variance in Python

后端 未结 2 1771
终归单人心
终归单人心 2021-01-07 06:37

In a Python program, I need to generate normally-distributed random numbers with a specific, user-controlled variance. How can I do this?

2条回答
  •  礼貌的吻别
    2021-01-07 06:55

    Use random.normalvariate (or random.gauss if you don't need thread-safety), and set the sigma argument to the square root of the variance.

提交回复
热议问题