def make_lpdf(mu, sigma):
    x = T.matrix()
    mu = theano.shared(mu)

    a = ( x.dimshuffle(0, 'x', 1) - mu.dimshuffle('x', 0, 1) ) / sigma

    E = log_mean_exp(-0.5*(a**2).sum(2))

    Z = mu.shape[1] * T.log(sigma * numpy.sqrt(numpy.pi * 2))

    return theano.function([x], E - Z)
Makes a Theano function that allows the evalution of a Parzen windows
dataset/ETHPy150Open lisa-lab/pylearn2/pylearn2/distributions/parzen.py/make_lpdf