MCPcopy Create free account
hub / github.com/numpy/numpy / rand

Function rand

numpy/matlib.py:231–275  ·  view source on GitHub ↗

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, ea

(*args)

Source from the content-addressed store, hash-verified

229 return asmatrix(np.eye(n, M=M, k=k, dtype=dtype, order=order))
230
231def rand(*args):
232 """
233 Return a matrix of random values with given shape.
234
235 Create a matrix of the given shape and propagate it with
236 random samples from a uniform distribution over ``[0, 1)``.
237
238 Parameters
239 ----------
240 \\*args : Arguments
241 Shape of the output.
242 If given as N integers, each integer specifies the size of one
243 dimension.
244 If given as a tuple, this tuple gives the complete shape.
245
246 Returns
247 -------
248 out : ndarray
249 The matrix of random values with shape given by `\\*args`.
250
251 See Also
252 --------
253 randn, numpy.random.RandomState.rand
254
255 Examples
256 --------
257 >>> np.random.seed(123)
258 >>> import numpy.matlib
259 >>> np.matlib.rand(2, 3)
260 matrix([[0.69646919, 0.28613933, 0.22685145],
261 [0.55131477, 0.71946897, 0.42310646]])
262 >>> np.matlib.rand((2, 3))
263 matrix([[0.9807642 , 0.68482974, 0.4809319 ],
264 [0.39211752, 0.34317802, 0.72904971]])
265
266 If the first argument is a tuple, other arguments are ignored:
267
268 >>> np.matlib.rand((2, 3), 4)
269 matrix([[0.43857224, 0.0596779 , 0.39804426],
270 [0.73799541, 0.18249173, 0.17545176]])
271
272 """
273 if isinstance(args[0], tuple):
274 args = args[0]
275 return asmatrix(np.random.rand(*args))
276
277def randn(*args):
278 """

Callers 15

xMethod · 0.85
test_booleanMethod · 0.85
_generate_int_dataMethod · 0.85
_generate_int32_dataMethod · 0.85
RandomFloatFunction · 0.85
test_basicMethod · 0.85
test_weightsMethod · 0.85
test_ndMethod · 0.85
test_bothMethod · 0.85
test_randomMethod · 0.85

Calls 1

asmatrixFunction · 0.90

Tested by 15

xMethod · 0.68
test_booleanMethod · 0.68
_generate_int_dataMethod · 0.68
_generate_int32_dataMethod · 0.68
RandomFloatFunction · 0.68
test_basicMethod · 0.68
test_weightsMethod · 0.68
test_ndMethod · 0.68
test_bothMethod · 0.68
test_randomMethod · 0.68