Q:

Numpy statistics, creating an array with certain statistics properties

If I have some numpy array, I can measure its mean, median, standard deviation, and so on with numpy routines, http://docs.scipy.org/doc/numpy/reference/routines.statistics.html
For example, for array arr, I would run
import numpy as np
print np.mean(arr) # prints the mean
print np.median(arr) # prints the median

However, for my purposes, instead of measuring the statistical properties after an array is created, I would like to create an array with data of distinct statistical properties. 
So, for example, I would like to create an array shaped (1000,) of mean 2.5, variance 10, data points i.i.d. such that they are Gaussian draws, etc. 
How could one do this with numpy? 

A:

You can use numpy.random.randn(size) which gives you normal(0,1) samples of length size.  So multiply by the standard deviation and add the mean:
import numpy as np
m = 2.5
std = np.sqrt(10)
v = m + std*np.random.randn(1000) 

print np.mean(v)  # 2.43375955445
print np.var(v)  # 9.9049376296

