megengine.random.poisson¶
- poisson(lam, size=None)¶
服从泊松分布 \(\operatorname{Poisson}(\lambda)\) 的随机变量。
对应的概率密度函数为
\[f(k ; \lambda)=\frac{\lambda^{k} e^{-\lambda}}{k !},\]其中 k 是出现的次数 \(({\displaystyle k=0,1,2...})\) 。
- 参数
- 返回
输出张量
实际案例
import megengine as mge import megengine.random as rand x = rand.poisson(lam=2., size=(1, 3)) print(x.numpy()) lam = mge.Tensor([[1.,1.], [10,10]], dtype="float32") x = rand.poisson(lam=lam) print(x.numpy()) x = rand.poisson(lam=lam, size=(1,3)) print(x.numpy())
输出:
[[3. 1. 3.]] [[ 2. 2.] [12. 11.]] [[[[ 1. 1.] [11. 4.]] [[ 0. 0.] [ 9. 13.]] [[ 0. 1.] [ 7. 12.]]]]