def compute_roc_auc(xs, ys, positiveYValue):
    """
    Compute area under the receiver operating curve...
    INPUTS:
        xs : predicted floating point values for each sample
        ys : truth for each sample
        positiveYValue : y value to treat as positive
    OUTPUT: computed AUC
    """
    def trapezoid_area(X1, X2, Y1, Y2):
        return 0.50*(X1 - X2)*(Y1 + Y2)

    # arrange the data, sorted by decreasing confidence xs values...
    data = sorted(zip(xs, ys), reverse = True)
    # check for degenerate case, all xs equal...
    if len(xs) == 0 or data[0][0] == data[-1][0]:
        # meaningless, so return 0.50 since no information is gained...
        return 0.50
    # count number of each class...
    P = float(ys.count(positiveYValue))
    N = len(ys) - P
    # check for degenerate cases...
    if P == 0.0 or N == 0.0:
        return 0.0
    # compute ROC points...
    TP = FP = 0.0
    TPprev = FPprev = 0.0
    fprev = None
    A = 0.0
    for x, y in data:
        if x != fprev:
            A += trapezoid_area(FP, FPprev, TP, TPprev)
            FPprev = FP
            TPprev = TP
            fprev = x
        if y == positiveYValue:
            TP += 1.0
        else:
            FP += 1.0
    A += trapezoid_area(N, FPprev, P, TPprev)
    A = A/(P*N)
    return A