⍝ Bayes:

    ⎕pp←5

    C←0.03                  ⍝ Probability of Cancer

    PRIOR←C,1-C             ⍝ Prior probabilities
    PRIOR
0.03 0.97

    COND←0.9 0.02           ⍝ Conditional probabilities

    COND bayes PRIOR        ⍝ Bayes Formula
0.5819 0.4181

    PRIORF←11 11 16÷38      ⍝ Pr(Party)
    PRIORF
0.28947 0.28947 0.42105

    CONDF←3 2 4÷11 11 16    ⍝ Pr(F|D),Pr(F|I),Pr(F|R)
    CONDF
0.27273 0.18182 0.25

    CONDF bayes PRIORF      ⍝ Pr(D|F),Pr(I|F),Pr(R|F)
0.33333 0.22222 0.44444

     3 2 4÷9                ⍝ Pr(Party|Female)
0.33333 0.22222 0.44444

Back to: code

Back to: Workspaces