ref https://numpy.org/doc/stable/reference/random/generated/numpy.random.choice.html
pythonimport numpy as np
np.random.seed(666)
# Return random floats in the half-open interval [0.0, 1.0).
print(np.random.random(size=[3, 6]))
print(np.random.random())
# Return random floats in the half-open interval [0.0, 1.0).
print(np.random.rand(3, 6))
print(np.random.rand())
# randint(low, high=None, size=None, dtype=int)
# [low, high) or [0, low)
print(np.random.randint(5, size=(2, 4)))
# [low, high) .samples from a uniform distribution.
print(np.random.uniform(-4, 4, 3))
# "standard normal" distribution.
print(np.random.randn(3, 6))
print(np.random.randn())
# Generates a random sample from a given 1-D array
print(np.random.choice(5, 3, p=[0.1, 0, 0.3, 0.6, 0]))
本文作者:Dong
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 CC BY-NC。本作品采用《知识共享署名-非商业性使用 4.0 国际许可协议》进行许可。您可以在非商业用途下自由转载和修改,但必须注明出处并提供原作者链接。 许可协议。转载请注明出处!