% Return Prob(B(n,p) ge k) where B(n,p) is binomial distribution
% Must have 0 le k le n and 0 le p le 1
function  pval = binomtail(k,n,p)
  if k<0 or k>n or p<0 or p>1  pval=-1.0;
  elseif k==0  pval=1.0;
  else  pval=betainc(p,k,n-k+1);  end;

