function Z=rvtail(X, k, pf) % rvtail(X, k, pf) Generates a column vector containing the percentage of % times the samples in each experiment in the random % variable matrix X was more than k standard deviations % away from the expected mean. For good result, pf should % be the probability function associated with X. if k<0 error('k < 0') end r=k*sqrt(var(pf)); M=size(X); Z=zeros(M(1),1); u=mmean(pf); for i=1:M(1), for j=1:M(2), if ~(inrange(X(i,j),u,r)) Z(i)=Z(i)+1; end end end Z=Z./M(2);