本文主要是介绍np.random.randint 与 np.random.rand区别 前者返回为参数指定的范围区间的一个整数后者返回的为一个概率,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
np.random.randint 与 np.random.rand区别 前者返回为参数指定的范围区间的一个整数后者返回的为一个概率
import numpy as np
num_lstm = np.random.randint(175, 275)
print(num_lstm)
print("np.random.rand()=",np.random.rand())
1 numpy.random.
randint
(low, high=None, size=None, dtype='l')¶
Return random integers from low (inclusive) to high (exclusive).
2
numpy.random.
rand
(d0, d1, ..., dn)
Random values in a given shape.
Create an array of the given shape and populate it with random samples from a uniform distribution over [0, 1)
.
参考
https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.random.rand.html#numpy.random.rand
#result
179 np.random.rand()= 0.46235794173895617
这篇关于np.random.randint 与 np.random.rand区别 前者返回为参数指定的范围区间的一个整数后者返回的为一个概率的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!