参考API:https://docs.scipy.org/doc/numpy/reference/routines.random.htmlhtml
API中关于该函数是这样描述的:dom
Modify a sequence in-place by shuffling its contents.
This function only shuffles the array along the first axis of a multi-dimensional array. The order of sub-arrays is changed but their contents remains the same.函数
也就是说,numpy.random,shuffle(x)是进行原地洗牌,直接改变x的值,而无返回值。对于多维度的array来讲,只对第一维进行洗牌,好比一个 $ 3 \times 3 $ 的array,只对行之间进行洗牌,而行内内容保持不变。
例子:
3d
API中关于该函数是这样描述的:htm
Randomly permute a sequence, or return a permuted range.
If x is a multi-dimensional array, it is only shuffled along its first index.blog
也就是说,numpy.random,permutation(x)是返回一个被洗牌过的array,而x不变。对于多维度的array来讲,只对第一维进行洗牌,好比一个 $ 3 \times 3 $ 的array,只对行之间进行洗牌,而行内内容保持不变。
例子:
ip