Skip to main content

numpy Cheat Sheet

random
random.randn
np.random.randn(d0, d1, ... , dn)

randn returns a sample (or samples) from the standard normal distribution

method type description
d0..dn int dimensions of the returned array
random.standard_normal
  np.random.standard_normal(size=None)

returns float-point array of shape size with standard normal distribution samples

method type description
size int or tuple or ints output shape (i.e., (m,n,k) => m * n * k)
cumsum
np.cumsum(a, axis=None, dtype=None, out=None)

returns a cumulative sum of the elements along a given axis