6Conditional Probability
Intuitively, the likelihood of one event occurring may well be influenced by the occurrence or otherwise of other events: for example, the probability that a student will not turn up to a lecture will be influenced by some other happening, such as maybe whether or not it is raining, or whether or not the freshers' ball was held the night before. This is conditional probability.
To motivate the idea, let us return to Table 4.1, where we considered data from a software development company, wherein 200 programs were written each week in either C++ or Java, with the following compiling frequencies:
Compiles | Does Not Compile | ||
on First Run | on First Run | ||
C++ | 72 | 48 | 120 |
Java | 64 | 16 | 80 |
136 | 64 | 200 |
Suppose, we now ask what the probability is that a program, chosen at random from the week's supply, compiles on the first run, given that we know it has been written in C++. In other words, we know that the program, which may or may not compile on the first run, has been selected from the 120 programs that were written in C++. In effect, the sample space reduces to the 120 programs written in C++, of which 72 compiled on the first run: thus the probability that the selected program will compile on the first run is .
Let us examine this further. Denote by C++ and Java, the events that a program is written in C++ and Java respectively, and let be the event ...
Get Probability with R, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.