% z = normal2d(x1,x2,mean2d,variance2d)
%
% generate values for a 2D normal distribution

function z = normal2d(x1, x2, dimensions, mean2d, variance2d, compvariances)
     
    m = length(x1);
    n = length(x2);
    z = zeros(n, m);
    C = 1 / sqrt((2*pi)^dimensions*prod(compvariances));
    S = inv(variance2d);

    for i=1:m
        for j=1:n
            x2d = [x1(i); x2(j)];
            z(j,i) = C * exp(-0.5 * (x2d-mean2d)' * S * (x2d-mean2d));
        end
    end
    







