numpy - numpy.random.rand

numpy.random.rand

numpy.random.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).

Parameters: d0, d1, …, dn : int, optional
The dimensions of the returned array, should all be positive. If no argument is given a single Python float is returned.

Returns:
out : ndarray, shape (d0, d1, …, dn)
Random values.

Notes
This is a convenience function. If you want an interface that takes a shape-tuple as the first argument, refer to np.random.random_sample .

strong@foreverstrong:~$ python
Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> np.random.rand(1)
array([ 0.71139204])
>>> 
>>> np.random.rand(2)
array([ 0.42395782,  0.00882576])
>>> 
>>> np.random.rand(2, 3)
array([[ 0.07985838,  0.99973964,  0.4833037 ],
       [ 0.94380213,  0.69696838,  0.86071621]])
>>> 
>>> np.random.rand(3, 2)
array([[ 0.15069669,  0.05796857],
       [ 0.31201132,  0.38995779],
       [ 0.59755402,  0.97105107]])
>>> 
>>> exit()
strong@foreverstrong:~$ 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值