Probability concept by Boolean Logic
By: Maulik Vyas
Tags: Data Science, Probability, Mathematics

I have first learned about probability in grade 10, and since then I have come across probability problems many times in college and then in university. But I was terrible at finding probabilities. I’d often randomly guess the answer. Sometimes, I’d refer any math books and some fancy online courses and then try to solve probability examples on my own but unfortunately, I’d hardly get the correct answer. Now, as I am working with Data Science problems almost every day, I have to calculate probabilities many times and so I decided to learn it thoroughly.

Recently, I learned a new way to find probability through Boolean Logic which was the easiest way I have ever encountered. Now I can calculate any problems very quickly, so I felt that a lot of people, who can’t solve the probability problems, can easily obtain accurate probability result next time from this article.

Definition

P robability of an event A is defined as the ratio of two numbers a and b is, P(A) = a/b, where a is the number of ways which are favorable to the occurrence of A and b is the total of the number of outcomes of the event.

In simple terms, probability refers to the chance or likelihood of a particular event happening.

Terminologies

Event: An event is an outcome of an experiment.

Experiment: An experiment is a process which is performed to understand and observe all possible outcomes.

Sample set: A sample set is a set of all outcomes of an experiment.

Addition Rules for computing probability

Addition rule for mutually exclusive events: P(A ∪ B) = P(A) + P(B). Addition rule for not mutually exclusive events: P(A ∪ B) = P(A) + P(B) - P(A ∩ B).

Probability by Boolean way

Suppose there are two events A and B which are not mutually exclusive then, the addition rule is,

P(A ∪ B) = P(A) + P(B) - P(A ∩ B). — — — (1)

Now, by using Boolean Theory, it can be proved that both the equations are the same.

The event A is counted as the addition of the event A taking place when the event B is present [A B] and when event B is not present [A (~B)] which is shown below:

A = A B + A (~B) ∴ A (~B) = A - A B

Similarly,

B = B A + B (~A) ∴ B (~A) = B - B A

Now,

A or B = A B + A (~B) + B (~A)

Put the values of A (~B) and B (~A) respectively in the above equation,

A or B = A B + A - A B + B - B A, where A B gets cancelled out,

therefore, the remaining part is A or B = A + B - A B

∴ P(A or B) = P(A) + P(B) - P(A and B)

∴ P(A ∪ B) = P(A) + P(B) - P(A ∩ B) which is equal to the first equation.

Examples

From a pack of well-shuffled cards, a card is drawn at random, then what is the probability that the selected card is a king or a diamond?

King (K) or Diamond (D) = K D + K (~D) + D (~K) = 1 + 3 + 12 = 16

Probability = Favorable instances / Total instances = 16 / 52

Note:

If for instance, for a king in a deck of cards, then there are two approaches you can take into consideration.

The frequency approach is where K + (~K) = 52 (because the total cards are 52). The proportional approach is where K + (~K) = 1 or 100 %.

The employees of a company were surveyed on their educational background (whether they have any degree or not) and marital status (either single or married). Out of 800 employees, 500 has college degrees, 200 were single, and 150 were single college graduates. The probability that an employee of the company is single or has a college degree is:

A boolean table to describe four different conditions.

Here, S refers to an employee being single, whereas (~S) means married. Likewise, D refers to having a college degree, while (~D) means not a college graduate.

Now, when we enter the values from the question, we get the following table.

Explanation of the above table

To begin with, we had 500 college graduates, so total D would be 500. Out of which 150 were single, so [S D] cell is filled up with 150. so, [(~S) D] cell would automatically be 500 - 150 = 350. Therefore, the first column is filled up.

Now, there were 200 single employees, so total S would be 200. Out of total 200 single employees, 150 were having a college degree, so the number of single employees who are not college graduates [S (~D)] cell would be 200 - 150 = 50. At last, the total number of employees who are neither single nor having any college degrees are 800 - [150 + 50 + 350] = 250.

The question is to find the probability of employees who are either single or have a college degree,

S or D = S D + (~S) D + S (~D) = 150 + 350 + 50 = 550 Probability (S ∪ D) = Favorable instances / Total instances = 550 / 800 = 11 / 16

Thus, this is how you can calculate any probability problems by creating a 2 x 2 table and then divide favorable events over total events.