function [imfl,imfh,imfl1,imfh1] = demarw(xpo,xprob) % [imfl,imfh,imfl1,imfh1] = fn_demarw(xpo,xprob) % Demarcate the .68 and .90 error bands given positions and properly scaled probabilities (weights). % % xpo: ndraws-by-n. Centered position % xprob: ndraws-by-n. Must be properly scaled probabilities corresponding to xpo. %----------------- % imfl: lower .90 bound, n-by-1 % imfh: higher .90 bound, n-by-1 % imfl1: lower .68 bound, n-by-1 % imfh1: higher .68 bound, n-by-1 % % August 1999 Tao Zha; Revised, August 2000 [ndraws,n]=size(xpo); %$$$ .68 and .95 probability bands imfl = zeros(n,1); % preallocating imfh = zeros(n,1); % preallocating imfl1 = zeros(n,1); % preallocating imfh1 = zeros(n,1); % preallocating imfpo = zeros(4,n); % 4 positions: l,h,l1,h1. % %tic tem = cumsum(xprob); % cumulative probability tem = tem .* 100; % %@@@ the following operations are valid only because tem are increasing! for k = 1:n % %@@@ the following operations are valid only because tem are increasing! %** 5% low tail if isempty(max(find(tem(:,k)<5))) imfl(k) = xpo(1,k); else imfl(k) = xpo(max(find(tem(:,k)<5)),k); end %** 16% low tail if isempty(max(find(tem(:,k)<16))) imfl1(k) = xpo(1,k); else imfl1(k) = xpo(max(find(tem(:,k)<16)),k); end %** 2.5% high tail imfh(k) = xpo(min(find(tem(:,k)>95)),k); %** 16% low tail imfh1(k) = xpo(min(find(tem(:,k)>84)),k); end