title: How do you work out Conditional Probabilities in Mathematica. Is it possible?
body: <p>Can Mathematica do Bayes Rule conditional probability calculations, without doing the calculation manually? If so how?</p>
  
  <p>I have been searching both the Mathemtaica doco and the web for a hint but cannot find anything. I am not after how to do Bayes Rule manually via Mathematica, I want to know if there is a way to define the conditional probabilities and calculate other ones automagically.</p>
  
  <p>So to use the toy example assuming Bernoulli distributions</p>
  
  <pre><code>P(Cancer+) = 0.01
  P(Cancer-) = 0.99
  
  P(Test+|Cancer+) = 0.9
  P(Test-|Cancer+) = 0.1
  P(Test+|Cancer-) = 0.2
  P(Test-|Cancer-) = 0.8
  </code></pre>
  
  <p>Is it possible to work out </p>
  
  <pre><code>P(Cancer+|Test+) = 0.0434
  </code></pre>
  
  <p>So using the below.</p>
  
  <pre><code>Print["P(C+) = ", PCancerT=BernoulliDistribution[0.01]];
  Print["P(C-) = ", PCancerF=BernoulliDistribution[0.99]];
  Print[]
  Print["P(T+|C+) = ", PTestTGivenCancerT=BernoulliDistribution[0.9]];
  Print["P(T-|C+) = ", PTestFGivenCancerT=BernoulliDistribution[0.1]];
  Print["P(T+|C-) = ", PTestTGivenCancerF=BernoulliDistribution[0.2]];
  Print["P(T-|C-) = ", PTestFGivenCancerF=BernoulliDistribution[0.8]];
  Print[]
  Print["P(T+,C+) = ", PTestTAndCancerT = Probability[vCT&amp;&amp;vTTCT,{vCT\[Distributed]PCancerT,vTTCT\[Distributed]PTestTGivenCancerT}]];
  Print["P(T-,C+) = ", PTestFAndCancerT = Probability[vCT&amp;&amp;vTFCF,{vCT\[Distributed]PCancerT,vTFCF\[Distributed]PTestFGivenCancerT}]];
  Print["P(T+,C-) = ", PTestTAndCancerF = Probability[vCF&amp;&amp;vTTCF,{vCF\[Distributed]PCancerF,vTTCF\[Distributed]PTestTGivenCancerF}]];
  Print["P(T-,C-) = ", PTestFAndCancerF = Probability[vCF&amp;&amp;vTTCF,{vCF\[Distributed]PCancerF,vTTCF\[Distributed]PTestFGivenCancerF}]];
  Print[]
  Print["P(C+|T+) = ?"];
  Print["P(C+|T-) = ?"];
  Print["P(C-|T+) = ?"];
  Print["P(C-|T-) = ?"];
  </code></pre>
  
  <p>I can work out the joint probabilities by defining all the probability tables manually, but is there a way to get Mathematica to do the heavy lifting?
  Is there a way to define and calculate these kind of conditional probabilities?</p>
  
  <p>Many thanks for any assistance, even it its “You can’t... stop trying” :) </p>
  
  <p>PS : was this an attempt at doing something along these lines?  <a href="https://stackoverflow.com/questions/5408149/symbolic-conditional-expectation-in-mathematica">Symbolic Conditional Expectation in Mathematica</a></p>