numpy.matlib.rand()

numpy.matlib.rand(*args) [source]

Return a matrix of random values with given shape.

Create a matrix of the given shape and propagate it with random samples from a uniform distribution over [0, 1).

Parameters:

*args : Arguments

Shape of the output. If given as N integers, each integer specifies the size of one dimension. If given as a tuple, this tuple gives the complete shape.

Returns:

out : ndarray

The matrix of random values with shape given by *args.

Examples

1
2
3
4
5
6
7
>>> import numpy.matlib
>>> np.matlib.rand(2, 3)
matrix([[ 0.683403820.679268870.83271405],
        [ 0.007935510.204682220.95253525]])       #random
>>> np.matlib.rand((2, 3))
matrix([[ 0.846820550.736265940.11308016],
        [ 0.854290080.3294825 0.89139555]])       #random

If the first argument is a tuple, other arguments are ignored:

1
2
3
>>> np.matlib.rand((2, 3), 4)
matrix([[ 0.468986460.151635880.95188261],
        [ 0.592086210.095618180.00583606]])       #random
doc_NumPy
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.