import random


def random_matrix (nrow, colmean, colsd):
  """Generate a random matrix of independent Gaussians,
with nrow being the number of rows, and with colmean
and colsd being vectors of column means and SDs, respectively."""

  assert(len(colmean) == len(colsd))
  assert(nrow > 0)

  ncol = len(colmean)

  # generate data as matrix, using nested list comprehension
  x = [[random.gauss(colmean[col], colsd[col]) for col in range(ncol)] for row in range(nrow)]

  return x