Project 21: Tree A or 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 below shows the probability of each possible event (the universe).

The probability of red then red is 2/15

The probability of red then blue is 4/15

The probability of blue then red is 12/45 = 4/15

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

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

Project 21: 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 'pAOrB' that represents the probability of A or B.  The value of p(A or B) is 10/15 = 2/3 for the first example which would represent the probability that either the first marble is red, or the second marble is red (or both).

**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