def calculate_roc_points(instances):
    """From a sorted list of instances, calculate the points that draw the ROC curve."""

    # Calculate the number of positives and negatives (the real ones).
    P = N = 0
    for label, score in instances:
        if label == 'p':
            P += 1
        else:
            N += 1

    # Calculate each point.
    TP = FP = 0
    points = []
    for label, score in instances:
        if label == 'p':
            TP += 1
        else:
            FP +=1
        point = (FP/N, TP/P)
        points.append(point)
    return points