Truncated Normal mean and variance
M=distfun_tnormstat(mu,sigma,a,b) [M,V]=distfun_tnormstat(mu,sigma,a,b)
a matrix of doubles, the average
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 mean
a matrix of doubles, the variance
Computes statistics from the Normal distribution.
The mean and variance of the Normal distribution are
![\begin{eqnarray}
M &=& \mu + \sigma \frac{\phi(\alpha)-\phi(\beta)}{Z}\\
V &=& \sigma^2 \left[1 + \frac{\alpha \phi(\alpha)-\beta\phi(\beta)}{Z}
- \left(\frac{\phi(\alpha)-\phi(\beta)}{Z}\right)^2\right]
\end{eqnarray}](./_LaTeX_distfun_tnormstat.xml_1.png)
Any scalar input argument is expanded to a matrix of doubles of the same size as the other input arguments.
mu = 1:6; sigma = 7:12; a=-10; b=10; [M,V]=distfun_tnormstat(mu,sigma,a,b) // Compare with random numbers a=-10; b=10; N=1000; // mu=-8; sigma=2; [M,V]=distfun_tnormstat(mu,sigma,a,b); x=distfun_tnormrnd(mu,sigma,a,b,N,1); [M,mean(x)] [V,variance(x)] // mu=0; sigma=2; [M,V]=distfun_tnormstat(mu,sigma,a,b); x=distfun_tnormrnd(mu,sigma,a,b,N,1); [M,mean(x)] [V,variance(x)] // mu=9; sigma=10; [M,V]=distfun_tnormstat(mu,sigma,a,b); x=distfun_tnormrnd(mu,sigma,a,b,N,1); [M,mean(x)] [V,variance(x)] // mu=0; sigma=10; [M,V]=distfun_tnormstat(mu,sigma,a,b); x=distfun_tnormrnd(mu,sigma,a,b,N,1); [M,mean(x)] [V,variance(x)] | ![]() | ![]() |
http://en.wikipedia.org/wiki/Truncated_normal_distribution