I have to build a2D array in python starting from a 1D array, where I use each element to start a new "orthogonal" 1D array. Suppose that I have an array that for each x gives me the probability given an underlying gaussian distribution. To better explain, I have a 1D array of x points, and for each x I want to generate a gaussian distribution N(x|mu,x1), where mu = x0-y[j]. Here y[j] is clearly the jth element along another 1D array. Then, I have to wait the gaussian I get by the probability of having that y[j], i.e. another gaussian. I did the following and it works, but it is too much time consuming, and I was wondering if there is an faster and more elegant way to implement this. Thank you.
import numpy
import matplotlib.pyplot as plt
parameters = [1.5, 0.17, 0.5,0.2]
x0, x1, y0, y1 = parameters
x = numpy.linspace(0,numpy.pi,600)
y = numpy.linspace(0, numpy.pi/2,500)
ygaussian = (1/(numpy.sqrt(2*numpy.pi)*y1))*numpy.exp(-0.5*((y-y0)/y1)**2)
W, V = numpy.meshgrid(x, y)
G = numpy.zeros((len(x),len(y)))
for i in range(len(x)):
for j in range(len(y)):
mu = x0 - y[j]
G[i,j] = (1/(numpy.sqrt(2*numpy.pi)*x1))*numpy.exp(-0.5*((x[i]-mu)/x1)**2)*ygaussian[j]
W, V = numpy.meshgrid(x,y)
plt.contourf(W,V,G.T)
plt.show()