random

np.random模塊dom

一、rand(d0, d1, ..., dn)spa

Random values in a given shape.orm

Create an array of the given shape and populate it with random samples from a uniform distribution over [0,1).ip

二、randn(d0, d1, ..., dn)ci

Return a sample (or samples) from the 「standard normal」 distribution.element

三、randint(low[, high, size, dtype])it

Return random integers from low (inclusive) to high (exclusive).io

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).form

四、random_integers(low[, high, size])class

Random integers of type np.int between low and high, inclusive.

五、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:

六、random([size])

Return random floats in the half-open interval [0.0, 1.0).

七、ranf([size])

Return random floats in the half-open interval [0.0, 1.0).

八、sample([size])

Return random floats in the half-open interval [0.0, 1.0).

九、choice(a[, size, replace, p])

Generates a random sample from a given 1-D array

十、bytes(length) Return random bytes.

 

一、np.ones(shape, dtype=None, order=’C’)

Return a new array of given shape and type, filled with ones.

二、np.zeros(shape, dtype=float, order=’C’)

Return a new array of given shape and type, filled with zeros.

三、np.eye(N, M=None, k=0, dtype=<type ‘float’>)
Return a 2-D array with ones on the diagonal and zeros elsewhere.

 

 

內置random模塊

一、random.gauss(mu, sigma)  Gaussian distribution高斯分佈

mu-->mean, sigma-->standard deviation

二、random.normavariate(mu, sigma)  Nomal distribution正態分佈

mu-->mean, sigma-->standard deviation

三、random.shuffle(x, random=None)

shuffle list x in place and return None.原地清洗列表x並返回None

四、random.choice(seq)

Choose a random element from a non-empty sequence.從非空序列中隨機選擇一個元素。

五、random.randint(a, b)

Return random integer in range [a, b], including both end points.從閉區間[a,b]返回一個隨機整數.

六、random.random()  在區間[0, 1)隨機生成一個小數

七、random.uniform(a, b)

Get a random number in the range [a, b) or [a, b] depending on rounding.根據數值修約在區間[a, b]返回一個隨機數

相關文章
相關標籤/搜索