% gaussian pdf

x = linspace(-3, 3, 100);

pdf = 1/sqrt(2*pi) * exp(-x.^2/2);

figure(1);
clf;
plot(x, pdf);
xlabel('x / \sigma');
ylabel('Probability density  p(x)');
grid on;
fixfig;

x = linspace(0, 3, 100);

pdf = 1/sqrt(2*pi) * exp(-x.^2/2);
cdf = abs(erf(x/sqrt(2)));

xx = [ 0.5 1 2 ];
px = 1/sqrt(2*pi) * exp(-xx.^2/2);
cx = abs(erf(xx/sqrt(2)));

figure(2);
subplot(2, 1, 1);
plot(x, pdf, '-', xx, px, 'ro');
ylabel('Probability density  p(x)');
grid on;
fixfig;

subplot(2, 1, 2);
plot(x, cdf, xx, cx, 'ro');
ylabel('P(-X \leq x \leq +X)');
xlabel('X');
grid on;
for i = 1:length(xx)
    text(xx(i), cx(i), sprintf('   %.1f%', 100*cx(i)));
end
fixfig;

xx = [ 0.2:0.2:4 ];
cc = 100 * abs(erf(xx/sqrt(2)));

[ xx; cc ]'