Truncated Normal PDF
y=distfun_tnormpdf(x,mu,sigma,a,b)
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 lower bound
a matrix of doubles, the upper bound (with a<=b)
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:
if x is in the [a,b] interval and zero otherwise, where
and is the standard normal cumulated distribution function (i.e. CDF),
and
is the standard normal probability distribution function (i.e. PDF).
y=distfun_tnormpdf([-2 -1 0 1],0,1,-1,1) expected = [ 0.241970724519143 0.241970724519143 ]; // Plot the function a=-10; b=10; x=linspace(a,b,1000); y1=distfun_tnormpdf(x,-8,2,a,b); y2=distfun_tnormpdf(x,0,2,a,b); y3=distfun_tnormpdf(x,9,10,a,b); y4=distfun_tnormpdf(x,0,10,a,b); scf(); plot(x,y1,"k-") plot(x,y2,"b-") plot(x,y3,"r-") plot(x,y4,"g-") xtitle("Truncated normal [-10,10]","X","PDF"); legend(["$\mu=-8,\sigma=2$","$\mu=0,\sigma=2$",.. "$\mu=9,\sigma=10$","$\mu=0,\sigma=10$"]); | ![]() | ![]() |
http://en.wikipedia.org/wiki/Truncated_normal_distribution