subroutine BINOMUP (m, N, beta, p_up, ierr) c Author: Glen Cowan c Date: 6-Jan-1998 c Computes the upper limit at a confidence level cl=1-beta for the c binomial parameter p, given m successes observed in N trials. c Must be linked with FFINV, ALNGAM, XINBTA, BETAIN. implicit NONE c arguments integer ierr ! 0 = ok integer m integer N real beta real p_up c local variables integer n1, n2 real cl real FFINV ! quantile of F distribution real q c begin ierr = 0 if ( m .lt. 0 ) then ierr = 1 elseif ( m .gt. N ) then ierr = 2 elseif ( beta .lt. 0. ) then ierr = 3 elseif ( beta .gt. 1. ) then ierr = 4 endif if ( ierr .ne. 0 ) then p_up = -1. return ! ---------------------> exit endif cl = 1. - beta if ( m .lt. N ) then n1 = 2*(m+1) n2 = 2*(N-m) q = FFINV (cl, n1, n2, ierr) p_up = FLOAT(m+1)*q / (FLOAT(N-m) + FLOAT(m+1)*q) elseif ( m .eq. N ) then p_up = 1. endif return END