什么是使用numpy生成正态分布整数集的最佳方法?我知道可以通过以下方式获得浮点数:
In [31]: import numpy as np
In [32]: import matplotlib.pyplot as plt
In [33]: plt.hist(np.random.normal(250, 1, 100))
Out[33]:
(array([ 2., 5., 9., 10., 19., 21., 13., 10., 6., 5.]),
array([ 247.52972483, 247.9913017 , 248.45287858, 248.91445546,
249.37603233, 249.83760921, 250.29918608, 250.76076296,
251.22233984, 251.68391671, 252.14549359]),
<a list of 10 Patch objects>)
np.random.normal(250, 1, 100).round(0)
? - tbcnp.random.normal(250, 1, 100).round().astype(np.int)
。(默认情况下,np.round
的值为0)。 - user707650