function val = qgaussian(dosample,var, mu, sigma)
% Proposal distribution used in sampling methods
%
% x = qgaussian(1, N,mu, sigma)
%     It returns the samples, according to the gaussian distribution
%     N: number of samples
%     mu, sigma: mean and std of the distribution
% q = qgraussian(0, x,mu, sigma)
%     It evaluetes the samples, according to the gaussian distribution
%     x: sample values
%     mu, sigma: mean and std of the distribution

% APRENDIZAJE AUTOMÁTICO (G. Pajares y J. M. de la Cruz, Eds.)
% Editorial: RA-MA
% Capítulo 7 y 8: Monte Carlo I y II
% Autores: Eva Besada-Portas, Sergey M. Plis


if dosample,
    N=var;
    x = randn(1,N) * sigma + mu;
    val=x;
else
    x=var;
    r = (1/(sigma*sqrt(2*pi)))*exp(-(x-mu).^2./(2.0*sigma^2));
    val=r;
end
