% normalpdf.m 
%
% written by Mariano Kulish
%
% Computes the PDF of a normal random variable with mean mu and standard
% deviation sigma
%
% y = normalpdf(x,mu,sigma)
%
% y = normalpdf(x) is normalpdf(x,0,1)
%
% y = normalpdf(x,mu) is normalpdf(x,mu,1)

function y = normalpdf(x,mu,sigma)

if nargin < 2;
   mu = 0; sigma = 1;
else
    if nargin < 3 ;
        sigma = 1;
    end
end


c = (2*pi)^.5; c = c*sigma; c = 1/c;

y = c*exp(-.5*((x-mu)/sigma).^2);

