函数 | 含义 |
---|---|
rand(*dn) | Create an array of the given shape and populate it with random samples from a uniform distribution over [0, 1) . |
random(arg) | 作用与rand差不多,得到的范围也是[0, 1) ,但这只能接受一个参数,可以是一个数字,也可以是一个tuple |
randn(*dn) | Return a sample (or samples) from the “standard normal” distribution.(得到是符合正态分布的随机数)*dn代表了要生成的是几维的 |
randint(low, high, size, dtype) | 在[low, high)之间,产生离散均匀分布的结果 |
normal(loc, scale, size) | 产生size个正态分布的结果,μ = loc, σ = scale |
import numpy as np
print(np.random.rand(3, 4))
print()
print(np.random.random((3,4)))
print()
print(np.random.randn(3,4))
print()
print(np.random.randint(low=2, high=10, size=8))
rand(*dn)
Create an array of the given shape and populate it with random samples from a uniform distribution over
[0, 1)
.
random(arg)
randn(*dn)
Return a sample (or samples) from the “standard normal” distribution.
randint(low, high, size, dtype)
Return random integers from the “discrete uniform” distribution of the specified dtype in the “half-open” interval [
low
,high
). Ifhigh
is None (the default), then results are from [0,low
).