[英]An analog to rnorm in python
早上好!
我希望在 R 中创建一些代码的模拟
基本上,我有一个 function,除其他外,它采用用户提供的种子(默认为 NULL)以及特定的分布(默认为 rnorm),并输出 9 个随机数,保存为向量“e”。 这就是它在 R 中的样子......
function (...other variables..., seed=NULL, dist=rnorm)
...other code...
e <- dist(9,...)
现在我正在将 function 转换为 Python,但我似乎无法找到一个可行的模拟,用户可以在其中替换基本种子和分发。
这是我到目前为止所拥有的...
def (...other variables..., seed=None, dist=?):
...other code...
e = dist(9)
见numpy.random.normal
function( 文档在这里)
例如:
import numpy as np
np.random.normal(0,1,9)
array([ 0.33593283, -0.18149502, 0.43148566, 1.46831794, -0.72244867,
-1.40048855, 0.52366471, 0.34099135, 0.71654992])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.