Consider the following problem with conditional probabilities: we toss a coin four times and we seek the

Question:

Consider the following problem with conditional probabilities: we toss a coin four times and we seek the probability that we get exactly two heads, if we know that

(i) the first outcome is heads;

(ii) the first two outcomes are both heads.

With the set of commands below, we obtain the desired probabilities. The way to tackle this in Mathematica is as follows: first, we create the complete sample space for the problem, then we find the restricted sample space (as it is defined by the event we condition upon) and, finally, we find the elements of the event of interest in this restricted sample space. As usual, the required probability is the ratio of the number of favorable events to the total number of possible events.
In[1]:= Print["Complete sample space"];
omeg=Flatten[Table[{i,j,k,l}, {i,0,1}, {j,0,1}, {k,0,1}, {l,0,1}],3]
Print["Restricted sample space (first outcome heads)"];
omeg1=Flatten[Table[{i,j,k,l}, {i,1,1}, {j,0,1}, {k,0,1}, {l,0,1}],3]
Print["Number of heads in each outcome of the restricted sample space"];
val1=Apply[Plus,omeg1,1]
Print["Restricted sample space (first two outcomes heads)"];
omeg11=Flatten[Table[{i,j,k,l}, {i,1,1}, {j,1,1}, {k,0,1}, {l,0,1}],3]
Print["Number of heads in each outcome of the restricted sample space"];
val11=Apply[Plus,omeg11,1]
Print["Probability of event (i) :" ,Count[val1,2]/Length[omeg1]];
Print["Probability of event (ii) :" ,Count[val11,2]/Length[omeg11]];
The output we obtain is given below.
Complete sample space Out[2]= {{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,0,1,1},{0,1,0,0}, {0,1,0,1},{0,1,1,0},{0,1,1,1},{1,0,0,0},{1,0,0,1}, {1,0,1,0},{1,0,1,1},{1,1,0,0},{1,1,0,1},{1,1,1,0}, {1,1,1,1}}
Restricted sample space (first outcome heads)
Out[3]= {{1,0,0,0},{1,0,0,1},{1,0,1,0},{1,0,1,1},{1,1,0,0}, {1,1,0,1},{1,1,1,0},{1,1,1,1}}
Number of heads in each outcome of the restricted sample space Out[4]= {1,2,2,3,2,3,3,4}
Restricted sample space (first two outcomes heads)
Out[5]= {{1,1,0,0},{1,1,0,1},{1,1,1,0},{1,1,1,1}}
Number of heads in each outcome of the restricted sample space Out[6]= {2,3,3,4}
Probability of event (i) :3/8 Probability of event (ii) :1/4 Proceeding in an analogous manner, obtain the conditional probabilities P(A|Bi) and P(Bi|A) in each of the following problems:

(a) We throw a die twice, and consider the events A: the sum of the two outcomes is 4, B1: the outcomes of the two throws are equal, B2: the outcome of the first throw is an even integer, B3: the outcome of the second throw is an odd integer, B4: the first outcome of the die is different from the second one.

(b) From a pack of 52 cards, we select two cards at random, and define the events A: both cards are aces, B1: the first card drawn is a diamond, and the second one is an ace, B2: the first card drawn is a spade, B3: both cards drawn are spades, B4: the two cards are not of the same suit.

(c) From a box with 10 balls numbered from 1 to 10, we select two balls without replacement, and let A: the numbers on the two balls drawn differ by at least 2 (in absolute value), B1: the numbers on the two balls drawn have a sum of squares greater than 10, B2: both numbers selected are even, B3: the numbers on the two balls have a sum less than 10.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question

Introduction To Probability Volume 2

ISBN: 9781118123331

1st Edition

Authors: Narayanaswamy Balakrishnan, Markos V. Koutras, Konstadinos G. Politis

Question Posted: