Probability table calculator

B (positive test) B̄ (negative test)
A (have "disease") TP    FN   
Ā (don't have disease) FP    TN   

P(x)=∑x/total
P(A):        P(B):
P(Ā):        P(B̄):

P(x|y)=P(xy)/P(y)=xy/∑y
P(A|B):   P(A|B̄):           P(B|A):   P(B|Ā):
P(Ā|B):   P(Ā|B̄):           P(B̄|A):   P(B̄|Ā):
If P(A)=P(A|B) then A, B are independent; P(B)=P(B|A). Rows and columns are multiples of each other

P(x or y)=P(x)+P(y)-P(xy)
P(AorB): (TP+FN+FP)/total     P(AorB̄): (TP+FN+TN)/total
P(ĀorB): (TP+FP+TN)/total     P(ĀorB̄): (FP+FN+TN)/total
If A and B are disjoint, i.e. no overlap P(AB)=0, then P(A or B)=P(A)+P(B).

Accuracies:
Sensitivity= TP/(TP+FN): % of those actually with the disease who are found. TP/prevalence
   FNR (false negative rate)=1-sensitivity:
Specificity= TN/(TN+FP): % correctly those without disease. TN/(1-prevalence). FPR (false positive rate)
   FPR (false positive rate)=1-specificity:

PPV: positive predictive value: TP/(TP+FP)=P(A|B)
NPV: negative predictive value: TN/(TN+FN)=P(Ā|B̄)

Bayes factor likelihood ratio= sensitivity/FPR: P(+|disease)/P(+|no disease)


Do by hand to learn. See patterns
1 1
1 2

1 2 
3 4

10 20
30 40

1 3
4 3
    
P(x)+P(x̄)=1 
P(x|y)+P(x̄|y)=1 ...

A,B disjoint
0 x
y 0    x,y not 0



smoker - CO oximetry
49 57
24 370

drug job applicants
45 5
25 480

driving&texting
731 3054
156 4564

marijuana test
119 3
24 154

cancer
8 2
99 891

polygraph  Rearranged!
42 9
15 32

INDEPENDENCE: rows and columns are multiples of each other
10 30
20 60

3blue1brown
9 1
89 901