簡體   English   中英

python 中的標准模擬

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM