Normal PDF
y=distfun_normpdf(x,mu,sigma)
a matrix of doubles, the outcome
a matrix of doubles, the mean
a matrix of doubles, the standard deviation. sigma>0.
a matrix of doubles, the density
Computes the probability distribution function of the Normal (Laplace-Gauss) function.
Any scalar input argument is expanded to a matrix of doubles of the same size as the other input arguments.
The function definition is:
computed = distfun_normpdf ( [-1 1] , 0 , 1 ) expected = [ 0.241970724519143 0.241970724519143 ]; // // Check expansion of mu and expansion of sigma computed = distfun_normpdf ( [1 2 3] , 1.0 , 2.0 ) expected = [ .. 0.199471140200716, .. 0.176032663382150, .. 0.120985362259572 .. ]; // Check with expanded arguments computed = distfun_normpdf ( [1 2 3] , [1 1 1], [2 2 2] ) // Plot the function mu = [0 0 0 -2]; sigma2 = [0.2 1.0 5.0 0.5]; cols = [1 2 3 4]; nf = size(cols,"*"); lgd = []; scf(); for k = 1 : nf x = linspace(-5,5,1000); y = distfun_normpdf ( x , mu(k) , sqrt(sigma2(k)) ); plot(x,y) str = msprintf("mu=%s, sigma^2=%s",.. string(mu(k)),string(sigma2(k))); lgd($+1) = str; end h = gcf(); for k = 1 : nf hk = h.children.children.children(nf - k + 1); hk.foreground = cols(k); end legend(lgd); xtitle("Normal PDF","x","y") | ![]() | ![]() |
http://en.wikipedia.org/wiki/Normal_distribution