MCPcopy
hub / github.com/numpy/numpy / rand

Function rand

numpy/matlib.py:233–277  ·  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

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

Callers 15

_create_dataMethod · 0.85
test_booleanMethod · 0.85
_generate_int_dataMethod · 0.85
_generate_int32_dataMethod · 0.85
test_basicMethod · 0.85
test_weightsMethod · 0.85
test_ndMethod · 0.85
test_bothMethod · 0.85
test_randomMethod · 0.85
test_simpleMethod · 0.85

Calls 1

asmatrixFunction · 0.90

Tested by 15

_create_dataMethod · 0.68
test_booleanMethod · 0.68
_generate_int_dataMethod · 0.68
_generate_int32_dataMethod · 0.68
test_basicMethod · 0.68
test_weightsMethod · 0.68
test_ndMethod · 0.68
test_bothMethod · 0.68
test_randomMethod · 0.68
test_simpleMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…