Truncated Normal CDF
p=distfun_tnormcdf(x,mu,sigma,a,b) p=distfun_tnormcdf(x,mu,sigma,a,b,lowertail)
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 1-by-1 matrix of booleans, the tail (default lowertail=%t). If lowertail is true (the default), then considers P(X<=x) otherwise P(X>x).
a matrix of doubles, the probability.
Computes the cumulated 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.
// Test expanded arguments p=distfun_tnormcdf([-2 1.5 3],[1 1 1],[2 2 2],0,2) expected = [0. 0.7577694 1.] // Test argument expansion computed=distfun_tnormcdf([-3 -1 1 2 3],1.,2.,-1,2) expected=[0. 0. 0.6406534 1. 1.] // Plot the function a=-10; b=10; x=linspace(a,b,1000); p1=distfun_tnormcdf(x,-8,2,a,b); p2=distfun_tnormcdf(x,0,2,a,b); p3=distfun_tnormcdf(x,9,10,a,b); p4=distfun_tnormcdf(x,0,10,a,b); scf(); plot(x,p1,"k-") plot(x,p2,"b-") plot(x,p3,"r-") plot(x,p4,"g-") xtitle("Truncated normal [-10,10]","X","CDF"); 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