def binom_test_reject_interval(value, nobs, alpha=0.05, alternative='two-sided'):
 if (alternative in ['2s', 'two-sided']):
  alternative = '2s'
  alpha = (alpha / 2)
 if (alternative in ['2s', 'smaller']):
  x_low = (stats.binom.ppf(alpha, nobs, value) - 1)
 else:
  x_low = 0
 if (alternative in ['2s', 'larger']):
  x_upp = (stats.binom.isf(alpha, nobs, value) + 1)
 else:
  x_upp = nobs
 return (x_low, x_upp)

def binom_test_reject_interval ( value , nobs , alpha = 0.05 , alternative = 'two-sided' ) : if ( alternative in [ '2s' , 'two-sided' ] ) : alternative = '2s' alpha = ( alpha / 2 ) if ( alternative in [ '2s' , 'smaller' ] ) : x_low = ( stats . binom . ppf ( alpha , nobs , value ) - 1 ) else : x_low = 0 if ( alternative in [ '2s' , 'larger' ] ) : x_upp = ( stats . binom . isf ( alpha , nobs , value ) + 1 ) else : x_upp = nobs return ( x_low , x_upp )
rejection region for binomial test for one sample proportion the interval includes the end points of the rejection region .