np.random子產品
1、rand(d0, d1, ..., dn)
Random values in a given shape.
Create an array of the given shape and populate it with random samples from a uniform distribution over [0,1).
2、randn(d0, d1, ..., dn)
Return a sample (or samples) from the “standard normal” distribution.
3、randint(low[, high, size, dtype])
Return random integers from low (inclusive) to high (exclusive).
Return random integers from the “discrete uniform” distribution of the specified dtype in the “half-open” interval [low, high). If high is None (the default), then results are from [0, low).
4、random_integers(low[, high, size])
Random integers of type np.int between low and high, inclusive.
5、random_sample([size])
Return random floats in the half-open interval [0.0, 1.0).
Results are from the “continuous uniform” distribution over the stated interval. To sample Unif[a, b), b > a multiply the output of random_sample by (b-a) and add a:
6、random([size])
7、ranf([size])
8、sample([size])
9、choice(a[, size, replace, p])
Generates a random sample from a given 1-D array
10、bytes(length) Return random bytes.
1、np.ones(shape, dtype=None, order=’C’)
Return a new array of given shape and type, filled with ones.
2、np.zeros(shape, dtype=float, order=’C’)
Return a new array of given shape and type, filled with zeros.
3、np.eye(N, M=None, k=0, dtype=<type ‘float’>)
Return a 2-D array with ones on the diagonal and zeros elsewhere.
内置random子產品
1、random.gauss(mu, sigma) Gaussian distribution高斯分布
mu-->mean, sigma-->standard deviation
2、random.normavariate(mu, sigma) Nomal distribution正态分布
3、random.shuffle(x, random=None)
shuffle list x in place and return None.原地清洗清單x并傳回None
4、random.choice(seq)
Choose a random element from a non-empty sequence.從非空序列中随機選擇一個元素。
5、random.randint(a, b)
Return random integer in range [a, b], including both end points.從閉區間[a,b]傳回一個随機整數.
6、random.random() 在區間[0, 1)随機生成一個小數
7、random.uniform(a, b)
Get a random number in the range [a, b) or [a, b] depending on rounding.根據數值修約在區間[a, b]傳回一個随機數