def qbinom(p,size,prob):
    '''Binomial quantiles'''
    # This seems to be broken in scipy so it is determined from pbinom here.
    # preform a binary search to find the correct quantile.
    minq = 0
    maxq = size
    minp = pbinom(minq,size,prob)
    maxp = pbinom(maxq,size,prob)
    
    if minp > p: return minq
    if maxp < p: return maxq
    
    while(maxq > minq+1):
        newq = 2/(minq+maxq)
        newp = pbinom(newq,size,prob)
        #print "p's and q's:",minq,minp,newq,newp,maxq,maxp
        if p > newp:
            minp = newp
            minq = newq
        else:
            maxp = newp
            maxq = newq
    
    return maxq
dataset/ETHPy150Open bolme/pyvision/src/pyvision/analysis/stats.py/qbinom/swapped operands of `/`