title: Generating 3D Gaussian distribution in Python
body: <p>I want to generate a Gaussian distribution in Python with the x and y dimensions denoting position and the z dimension denoting the magnitude of a certain quantity.</p>
  
  <p>The distribution has a maximum value of 2e6 and a standard deviation sigma=0.025.</p>
  
  <p>In MATLAB I can do this with:</p>
  
  <pre><code>x1 = linspace(-1,1,30);
  x2 = linspace(-1,1,30);
  
  mu = [0,0];
  Sigma = [.025,.025];
  
  [X1,X2] = meshgrid(x1,x2);
  F = mvnpdf([X1(:) X2(:)],mu,Sigma);
  F = 314159.153*reshape(F,length(x2),length(x1));
  surf(x1,x2,F);
  </code></pre>
  
  <p>In Python, what I have so far is:</p>
  
  <pre><code>x = np.linspace(-1,1,30)
  y = np.linspace(-1,1,30)
  
  mu = (np.median(x),np.median(y))
  
  sigma = (.025,.025)
  </code></pre>
  
  <p>There is a Numpy function numpy.random.multivariate_normal what can supposedly do the same as MATLAB's mvnpdf, but I am struggling to undestand the <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.random.multivariate_normal.html" rel="nofollow">documentation</a>. Especially in obtaining the covariance matrix needed by numpy.random.multivariate_normal.</p>