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)
| 231 | return asmatrix(np.eye(n, M=M, k=k, dtype=dtype, order=order)) |
| 232 | |
| 233 | def 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 | |
| 279 | def randn(*args): |
| 280 | """ |
searching dependent graphs…