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:~$