當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python mxnet.ndarray.random.poisson用法及代碼示例

用法:

mxnet.ndarray.random.poisson(lam=1, shape=_Null, dtype=_Null, ctx=None, out=None, **kwargs)

參數

  • lam(float or NDArray, optional) - 間隔的期望值,應該 >= 0。
  • shape(int or tuple of ints, optional) - 要繪製的樣本數。如果形狀是,例如,(m, n)lam是一個標量,輸出形狀將是(m, n).如果lam是具有形狀的 NDArray,例如,(x, y),則輸出將具有形狀(x, y, m, n),其中m*n為每個條目抽取樣本lam.
  • dtype({'float16', 'float32', 'float64'}, optional) - 輸出樣本的數據類型。默認為‘float32’
  • ctx(mxnet.context.Context, optional) - 輸出的設備上下文。默認為當前上下文。被覆蓋lam.contextlam是一個 NDArray。
  • out(NDArray, optional) - 將輸出存儲到現有的 NDArray。

返回

如果輸入 shape 具有形狀,例如 (m, n)lam 是標量,則輸出形狀將為 (m, n) 。如果 lam 是具有形狀的 NDArray,例如 (x, y) ,則輸出將具有形狀 (x, y, m, n) ,其中為 lam 中的每個條目繪製 m*n 樣本。

返回類型

ND陣列

從泊鬆分布中抽取隨機樣本。

樣本根據由lambda(速率)參數化的泊鬆分布分布。樣本將始終作為浮點數據類型返回。

例子

>>> mx.nd.random.poisson(1)
[ 1.]
<NDArray 1 @cpu(0)>
>>> mx.nd.random.poisson(1, shape=(2,))
[ 0.  2.]
<NDArray 2 @cpu(0)>
>>> lam = mx.nd.array([1,2,3])
>>> mx.nd.random.poisson(lam, shape=2)
[[ 1.  3.]
 [ 3.  2.]
 [ 2.  3.]]
<NDArray 3x2 @cpu(0)>

相關用法


注:本文由純淨天空篩選整理自apache.org大神的英文原創作品 mxnet.ndarray.random.poisson。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。