作为np.random
是PRNG,它可以接种和它的种子被手动设置为可再现的结果。现在,它正在接种1和种子然后np.random.random()
构建你重置为1
In [4]: np.random.seed?
Docstring:
seed(seed=None)
Seed the generator.
This method is called when `RandomState` is initialized. It can be
called again to re-seed the generator. For details, see `RandomState`.
Parameters
----------
seed : int or array_like, optional
Seed for `RandomState`.
Must be convertible to 32 bit unsigned integers.
随机值矩阵后,你会总是得到相同的结果:
In [5]: np.random.random?
Docstring:
random_sample(size=None)
Return random floats in the half-open interval [0.0, 1.0).
其余的是通常的numpy算术。 A - 1
用于矩阵A
意味着减去1逐元素从A
。而2 * A
是正常的标量操作。