def cibinom(size,success,alpha=0.05):
    '''Confidence interval for a binomial distribution.'''
    goal = 0.5*alpha
        
    # find the upper limit
    lower_prob = 0.0
    #lower_p    = pbinom(success,size,lower_prob)
    upper_prob = 1.0
    #upper_p    = pbinom(success,size,upper_prob)
        
    for _ in range(32):
        new_prob = (lower_prob + upper_prob)*0.5
        new_p    = pbinom(success,size,new_prob)
        
        if goal < new_p:
            upper_prob = new_prob
            #upper_p = new_p
        else:
            lower_prob = new_prob
            #lower_p = new_p
            
    ub = upper_prob
       
       
       
    #find the lower limit
    success = size - success
    lower_prob = 0.0
    #lower_p    = pbinom(success,size,lower_prob)
    upper_prob = 1.0
    #upper_p    = pbinom(success,size,upper_prob)
        
    for _ in range(64):
        new_prob = (lower_prob + upper_prob)*0.5
        new_p    = pbinom(success,size,new_prob)
        
        if new_p < goal:
            upper_prob = new_prob
            #upper_p = new_p
        else:
            lower_prob = new_prob
            #lower_p = new_p
            
    lb = 1-upper_prob
    
    return (lb,ub)
dataset/ETHPy150Open bolme/pyvision/src/pyvision/analysis/stats.py/cibinom/swapped operands of `<`