Pretty trivial if you have a math library, I don't see anything here that is special. Why not give it a shot yourself?
http://docs.scipy.org/doc/numpy/reference/ufuncs.html
http://docs.scipy.org/doc/numpy/reference/routines.random.ht...
http://docs.scipy.org/doc/numpy/reference/generated/numpy.nd...
;)