Debian Codegraph @

contrib/ms-sbvar/TZcode/MatlabFiles/lcnmean.m

raw
1 function cutmean = lcnmean(x,pnIndx)
2 %
3 % cutmean = lcnmean(x,pnIndx)
4 %
5 % The mean of the truncated normal with the lower bound x if pnIndx>0
6 % or the upper bound x if pnIndx<0. Zha Forecast (2) p.27
7 %
8 % x: the lower bound x if pnIndx > 0; the upper bound x if pnIndx < 0
9 % pnIndx: 1: truncated for posivie mean (tight); 0 truncated for negative mean (loose)
10 %------------
11 % cutmean: the backed-out mean for the truncated normal
12 %
13 % October 1998 Tao Zha
14 %
15 % Copyright (C) 1997-2012 Tao Zha
16 %
17 % This free software: you can redistribute it and/or modify
18 % it under the terms of the GNU General Public License as published by
19 % the Free Software Foundation, either version 3 of the License, or
20 % (at your option) any later version.
21 %
22 % It is distributed in the hope that it will be useful,
23 % but WITHOUT ANY WARRANTY; without even the implied warranty of
24 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 % GNU General Public License for more details.
26 %
27 % If you did not received a copy of the GNU General Public License
28 % with this software, see <http://www.gnu.org/licenses/>.
29 %
30
31 if pnIndx
32 cutmean = exp(-x^2/2)/(sqrt(2*pi)*(1-cdf('norm',x,0,1)));
33 else
34 cutmean = -exp(-x^2/2)/(sqrt(2*pi)*cdf('norm',x,0,1));
35 end