| 1 |
function [imfl,imfh,imfl1,imfh1] = demarw(xpo,xprob) |
| 2 |
% [imfl,imfh,imfl1,imfh1] = demarw(xpo,xprob) |
| 3 |
% Demarcate the .68 and .95 error bands given prob. (weights) and positions |
| 4 |
% |
| 5 |
% xpo: ndraws-by-nvar. Centered position |
| 6 |
% xprob: ndraws-by-nvar. Properly scaled probabilities corresponding to xpo. |
| 7 |
%----------------- |
| 8 |
% imfl: lower .95 bound, nvar-by-1 |
| 9 |
% imfh: higher .95 bound, nvar-by-1 |
| 10 |
% imfl1: lower .68 bound, nvar-by-1 |
| 11 |
% imfh1: higher .68 bound, nvar-by-1 |
| 12 |
% |
| 13 |
% |
| 14 |
% Copyright (C) 1997-2012 Tao Zha |
| 15 |
% |
| 16 |
% This free software: you can redistribute it and/or modify |
| 17 |
% it under the terms of the GNU General Public License as published by |
| 18 |
% the Free Software Foundation, either version 3 of the License, or |
| 19 |
% (at your option) any later version. |
| 20 |
% |
| 21 |
% It is distributed in the hope that it will be useful, |
| 22 |
% but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 23 |
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 24 |
% GNU General Public License for more details. |
| 25 |
% |
| 26 |
% If you did not received a copy of the GNU General Public License |
| 27 |
% with this software, see <http://www.gnu.org/licenses/>. |
| 28 |
% |
| 29 |
|
| 30 |
|
| 31 |
[ndraws,nvar]=size(xpo); |
| 32 |
|
| 33 |
%$$$ .68 and .95 probability bands |
| 34 |
imfl = zeros(nvar,1); % preallocating |
| 35 |
imfh = zeros(nvar,1); % preallocating |
| 36 |
imfl1 = zeros(nvar,1); % preallocating |
| 37 |
imfh1 = zeros(nvar,1); % preallocating |
| 38 |
imfpo = zeros(4,nvar); % 4 positions: l,h,l1,h1. |
| 39 |
% |
| 40 |
%tic |
| 41 |
tem = cumsum(xprob); % cumulative probability |
| 42 |
tem = tem .* 100; |
| 43 |
% |
| 44 |
%@@@ the following operations are valid only because tem are increasing! |
| 45 |
for k = 1:nvar |
| 46 |
% |
| 47 |
%@@@ the following operations are valid only because tem are increasing! |
| 48 |
%** 2.5% low tail |
| 49 |
if isempty(max(find(tem(:,k)<2.5))) |
| 50 |
imfl(k) = xpo(1,k); |
| 51 |
else |
| 52 |
imfl(k) = xpo(max(find(tem(:,k)<2.5)),k); |
| 53 |
end |
| 54 |
%** 16% low tail |
| 55 |
if isempty(max(find(tem(:,k)<16))) |
| 56 |
imfl1(k) = xpo(1,k); |
| 57 |
else |
| 58 |
imfl1(k) = xpo(max(find(tem(:,k)<16)),k); |
| 59 |
end |
| 60 |
%** 2.5% high tail |
| 61 |
imfh(k) = xpo(min(find(tem(:,k)>97.5)),k); |
| 62 |
%** 16% low tail |
| 63 |
imfh1(k) = xpo(min(find(tem(:,k)>84)),k); |
| 64 |
end |