rand(d0, d1, ..., dn) | 随机值 >>> np.random.rand(3,2)array([[ 0.14022471, 0.96360618], #random [ 0.37601032, 0.25528411], #random [ 0.49313049, 0.94909878]]) #random |
randn(d0, d1, ..., dn) | 返回一个样本,具有标准正态分布。 Notes For random samples from [R217]).
Examples Draw samples from the distribution: >>> mu, sigma = 0, 0.1 # mean and standard deviation>>> s = np.random.normal(mu, sigma, 1000) Verify the mean and the variance: >>> abs(mu - np.mean(s)) < 0.01True>>> abs(sigma - np.std(s, ddof=1)) < 0.01True Display the histogram of the samples, along with the probability density function: >>> import matplotlib.pyplot as plt>>> count, bins, ignored = plt.hist(s, 30, normed=True)>>> plt.plot(bins, 1/(sigma * np.sqrt(2 * np.pi)) *... np.exp( - (bins - mu)**2 / (2 * sigma**2) ),... linewidth=2, color=‘r‘)>>> plt.show()
|
pareto(a[, size]) | 帕累托(Lomax)分布 |
poisson([lam, size]) | 泊松分布 |
power(a[, size]) | Draws samples in [0, 1] from a power distribution with positive exponent a - 1. |
rayleigh([scale, size]) | Rayleigh 分布 |
standard_cauchy([size]) | 标准柯西分布 |
standard_exponential([size]) | 标准的指数分布 |
standard_gamma(shape[, size]) | 标准伽马分布 |
standard_normal([size]) | 标准正态分布 (mean=0, stdev=1). |
standard_t(df[, size]) | Standard Student’s t distribution with df degrees of freedom. |
triangular(left, mode, right[, size]) | 三角形分布 |
uniform([low, high, size]) | 均匀分布 |
vonmises(mu, kappa[, size]) | von Mises分布 |
wald(mean, scale[, size]) | 瓦尔德(逆高斯)分布 |
weibull(a[, size]) | Weibull 分布 |
zipf(a[, size]) | 齐普夫分布 |
Container for the Mersenne Twister pseudo-random number generator. | |
seed([seed]) | Seed the generator. |
Return a tuple representing the internal state of the generator. | |
set_state(state) | Set the internal state of the generator from a tuple. |
联系客服