def confusion_matrix(precision, recall, positives, universe):
    """
    Given precision and recall for a test, as well as the number of positive results and the size of the tested space (universe),
    return a dictionary with the expected fraction of true positives, false positives, true negatives and false negatives, as well as their
    absolute numbers given the size of the universe, as well as estimates of the Real Positives and Real Negatives.
    """
    assert recall > 0
    TP = precision * positives
    TPF = TP / float(universe)
    FP = (1 - precision) * positives
    FPF = FP / float(universe)
    TN = universe - TP - FP
    TNF = TN / float(universe)
    FN = TP * (1 - recall) / recall
    FNF = FN / float(universe)
    RP = max(0, min(universe, TP + FN))
    RPF = RP / float(universe)
    RN = universe - RP
    RNF = RN / float(universe)
    TPR = recall
    TNR = TN / float(RN)
    FPR = FP / float(RN)
    return {'TP': TP, 'TPF': TPF, 'FP': FP, 'FPF': FPF, 'TN': TN, 'TNF':
        TNF, 'FN': FN, 'FNF': FNF, 'RP': RP, 'RPF': RPF, 'RN': RN, 'RNF':
        RNF, 'TPR': TPR, 'TNR': TNR, 'specificity': TNR, 'FPR': FPR,
        'sensitivity': recall}
