python np random choice,python numpy之np.random的随机数函数使用介绍

np.random的随机数函数(1)

函数

说明

rand(d0,d1,..,dn)

根据d0‐dn创建随机数数组,浮点数, [0,1),均匀分布

randn(d0,d1,..,dn)

根据d0‐dn创建随机数数组,标准正态分布

randint(low[,high,shape])

根据shape创建随机整数或整数数组,范围是[low, high)

seed(s)

随机数种子, s是给定的种子值

np.random.rand

import numpy as np

a = np.random.rand(3, 4, 5)

a

Out[3]:

array([[[0.28576737, 0.96566496, 0.59411491, 0.47805199, 0.97454449],

[0.15970049, 0.35184063, 0.66815684, 0.13571458, 0.41168113],

[0.66737322, 0.91583297, 0.68033204, 0.49083857, 0.33549182],

[0.52797439, 0.23526146, 0.39731129, 0.26576975, 0.26846021]],

[[0.46860445, 0.84988491, 0.92614786, 0.76410349, 0.00283208],

[0.88036955, 0.01402271, 0.59294569, 0.14080713, 0.72076521],

[0.0537956 , 0.08118672, 0.59281986, 0.60544876, 0.77931621],

你可能感兴趣的:(python,np,random,choice)