
clear 
close all

% Define a Gaussian probability density function and draw samples from it

s=.5;  % in s this is for the hypocentre location problem

% Define interval and discrete space
t=-5:.01:5;

% Calculate pdf
gauss=1./(sqrt(2*pi)*s)*exp(-.5/s^2*t.^2);

n=50000;
for i=1:n, 
    sample(i)=draw_from_pdf(t,gauss);
end

% check std
s_est=std(sample);

subplot(211), hist(sample,100), axis([-2 2 -Inf Inf])
title(' Histrogram from drawn samples ')
ylabel(' Frequency ' )
xlabel(' Time error (s) ')
subplot(212), plot(t,gauss), axis([-2 2 -Inf Inf])
title(' Gauss pdf ')
ylabel(' Probability ' )
xlabel(' Time error (s) ')