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

Function randn

numpy/matlib.py:277–328  ·  view source on GitHub ↗

Return a random matrix with data from the "standard normal" distribution. `randn` generates a matrix filled with random floats sampled from a univariate "normal" (Gaussian) distribution of mean 0 and variance 1. Parameters ---------- \\*args : Arguments Shape of th

(*args)

Source from the content-addressed store, hash-verified

275 return asmatrix(np.random.rand(*args))
276
277def randn(*args):
278 """
279 Return a random matrix with data from the "standard normal" distribution.
280
281 `randn` generates a matrix filled with random floats sampled from a
282 univariate "normal" (Gaussian) distribution of mean 0 and variance 1.
283
284 Parameters
285 ----------
286 \\*args : Arguments
287 Shape of the output.
288 If given as N integers, each integer specifies the size of one
289 dimension. If given as a tuple, this tuple gives the complete shape.
290
291 Returns
292 -------
293 Z : matrix of floats
294 A matrix of floating-point samples drawn from the standard normal
295 distribution.
296
297 See Also
298 --------
299 rand, numpy.random.RandomState.randn
300
301 Notes
302 -----
303 For random samples from the normal distribution with mean ``mu`` and
304 standard deviation ``sigma``, use::
305
306 sigma * np.matlib.randn(...) + mu
307
308 Examples
309 --------
310 >>> np.random.seed(123)
311 >>> import numpy.matlib
312 >>> np.matlib.randn(1)
313 matrix([[-1.0856306]])
314 >>> np.matlib.randn(1, 2, 3)
315 matrix([[ 0.99734545, 0.2829785 , -1.50629471],
316 [-0.57860025, 1.65143654, -2.42667924]])
317
318 Two-by-four matrix of samples from the normal distribution with
319 mean 3 and standard deviation 2.5:
320
321 >>> 2.5 * np.matlib.randn((2, 4)) + 3
322 matrix([[1.92771843, 6.16484065, 0.83314899, 1.30278462],
323 [2.76322758, 6.72847407, 1.40274501, 1.8900451 ]])
324
325 """
326 if isinstance(args[0], tuple):
327 args = args[0]
328 return asmatrix(np.random.randn(*args))
329
330def repmat(a, m, n):
331 """

Callers 4

_generate_dataMethod · 0.85
_generate_flt_dataMethod · 0.85

Calls 1

asmatrixFunction · 0.90

Tested by 4

_generate_dataMethod · 0.68
_generate_flt_dataMethod · 0.68