function P=pval(cf, x) % pval(cf, x) gets the approximate P value for the given cumulative % function at the given x. F(). if iscf(cf)==0 error('invalid cumulative function') end X=xvals(cf); p=pvals(cf); x=x(:)'; P=zeros(size(x)); LB=min(X); UB=max(X); if isdiscrt(cf)==0 R=UB-LB; for i=1:length(x), if x(i)UB P(i)=1; else index=round((x(i)-LB)/R*length(X)+0.5); if index>length(X) index=length(X); end P(i)=p(index); end end else for i=1:length(x), index=1; if x(i)=UB P(i)=1; else index=1; while X(index)<=x(i) & index