Project 45: Tree Prob A Given B

Suppose a hat has 4 red marbles and 6 blue marbles.  If we were to pick two marbles from the hat, the tree diagram to the right shows the probability of each possible event (the universe).

The probability of red then red is (2/5)(1/3) = 2/15

The probability of red then blue is (2/5)(2/3) = 4/15

The probability of blue then red is (3/5)(4/9) = 12/45 = 4/15

The probability of blue then blue is 1(3/5)(5/9) = 5/45 = 5/15  (or 1/3)

The sum of these four probabilities is 15/15 = 1

Project 45: Variables 'pA', 'pBGivenA', and 'pNBGivenNA' have been initialized.  

the probability of A (2/5 in the first example)

 the probability of B given A (1/3 in the first example)

the probability of not B given not A (5/9 in the first example)

Task: Appropriately initialize the value of 'pAGivenB' that represents the probability of A given B.  The value of p(A|B) is 1/3 (2/15 divided by 6/15) for the first example which would represent the probability that the first marble is red given that the second marble is red.

**If your code works for 5 test cases, you can enter your e-mail address

Universal Computational Math Methods:

pow(5,2) returns 25.0

abs(-3.0) returns 3

sqrt(49.0) returns 7.0