Compound Gaussian distribution using matlab

434 Views Asked by At

I want to ask how can we generate Compound Gaussian distribution using matlab?

1

There are 1 best solutions below

0
On

If by compound you mean bivariate, here is how you plot it in Matlab.

% This program plots the bivariate Gaussian with mean = 0 and sigma = 1

close all

x = (-3:0.1:3)';
y = x;
rho = 0.999;
pxy = zeros(length(x), length(y));
ux = 0;      % mean of x
uy = 0;      % mean of y
sx = 1;      % sigma x
sy = 1;      % sigma y

for i = 1:length(x)
    for j = 1:length(y)
        Q = (x(i) - ux)^2/sx - 2*rho*(x(i) - ux)*(y(j) - uy)/(sx*sy) +... 
            (y(j) - uy)^2/sy;
        pxy(i, j) = 1/(2*pi*sqrt(1 - rho^2))*exp(-1/(2*(1 - rho^2))*Q);
    end
end

figure(1)
mesh(x, y, pxy');
axis([-3 3 -3 3 0 5]);
view(-30, 36);
xlabel('x');
ylabel('y');
zlabel('z');

figure(2)
[C, H] = contour(x, y, pxy);
axis('square');
xlabel('x');
ylabel('y');
grid on

enter image description here

With sx = 200 and sy = 300, we generate the following Gaussian

enter image description here