clear;

X = (-100:1:100);
x1 = 20; x2 = -50; sig1 = 15; sig2 = 15; 
Z = 0.5*exp(-((X-x1).^2)/(2*sig1*sig1)) + 0.5*exp(-((X-x2).^2)/(2*sig2*sig2));
plot(X,Z);

N = 200;
a = zeros(200,1);

for i=1:N
    v = rand(1); 
    if v <= 0.5
        a(i) = randn(1)*sig1+x1;    % samples from a 2-dimensional Gaussian with mean vector [x1 y1] and covariance matrix C1 defined above
    else
        a(i) = randn(1)*sig2+x2;    %  samples from a 2-dimensional Gaussian with mean vector [x2 y2] and covariance matrix C2 defined above       
    end
end
figure, scatter(a,ones(1,N));