Login
📚 Principles of Data Science
Chapters ▾
⇩ Download ▾

3.4 Probability Theory

Learning Outcomes

By the end of this section, you should be able to:

  • Describe the basic concepts of probability and apply these concepts to real-world applications in data science.
  • Apply conditional probability and Bayes’ Theorem.

Probability is a numerical measure that assesses the likelihood of occurrence of an event. Probability applications are ubiquitous in data science since many decisions in business, science, and engineering are based on probability considerations. We all use probability calculations every day as we decide, for instance, whether to take an umbrella to work, the optimal route for a morning commute, or the choice of a college major.

Basic Concepts of Probability

We have all used probability in one way or another on a day-to-day basis. Before leaving the house, you might want to know the probability of rain. The probability of obtaining heads on one flip of a coin is one-half, or 0.5.

A data scientist is in interested in expressing probability as a number between 0 and 1 (inclusive), where 0 indicates impossibility (the event will not occur) and 1 indicates certainty (the event will occur). The probability of an event falling between 0 and 1 reflects the degree of uncertainty associated with the event.

Here is some terminology we will be using in probability-related analysis:

  • An outcome is the result of a single trial in a probability experiment.
  • The sample space is the set of all possible outcomes in a probability experiment.
  • An event is some subset of the sample space. For example, an event could be rolling an even number on a six-sided die. This event corresponds to three outcomes, namely rolling a 2, 4, or 6 on the die.

To calculate probabilities, we can use several approaches, including relative frequency probability, which is based on actual data, and theoretical probability, which is based on theoretical conditions.

Relative Frequency Probability

Relative frequency probability is a method of determining the likelihood of an event occurring based on the observed frequency of its occurrence in a given sample or population. A data scientist conducts or observes a procedure and determines the number of times a certain Event A occurs. The probability of Event A, denoted as P(A), is then calculated based on data that has been collected from the experiment, as follows:

P(A)=number of times Event A has occurednumber of times the procedure was repeated

Theoretical Probability

Theoretical probability is the method used when the outcomes in a probability experiment are equally likely—that is, under theoretical conditions.

The formula used for theoretical probability is similar to the formula used for empirical probability. Theoretical probability considers all the possible outcomes for an experiment that are known ahead of time so that past data is not needed in the calculation for theoretical probability.

Theoretical Probability=number of outcomes for the event of interesttotal number of outcomes in the sample space

For example, the theoretical probability of rolling an even number when rolling a six-sided die is 36 (which is 12, or 0.5). There are 3 outcomes corresponding to rolling an even number, and there are 6 outcomes total in the sample space. Notice this calculation can be done without conducting any experiments since the outcomes are equally likely.

Notice in Example 3 that probabilities can be written as fractions, decimals, or percentages.

Also note that any probability must be between 0 and 1 inclusive. An event with a probability of zero will never occur, and an event with a probability of 1 is certain to occur. A probability greater than 1 is not possible, and a negative probability is not possible.

Complement of an Event

The complement of an event is the set of all outcomes in the sample space that are not included in the event. The complement of Event A is usually denoted by A (A prime). To find the probability of the complement of Event A, subtract the probability of Event A from 1.

P(A)=1P(A)

Conditional Probability and Bayes’ Theorem

Data scientists are often interested in determining conditional probabilities, or the occurrence of one event that is conditional or dependent on another event. For example, a medical researcher might be interested to know if an asthma diagnosis for a patient is dependent on the patient’s exposure to air pollutants. In addition, when calculating conditional probabilities, we can sometimes revise a probability estimate based on additional information that is obtained. As we’ll see in the following section, Bayes’ Theorem allows new information to be used to refine a probability estimate.

Conditional Probability

A conditional probability is the probability of an event given that another event has already occurred. The notation for conditional probability is P(A|B), which denotes the probability of Event A, given that Event B has occurred. The vertical line between A and B denotes the “given” condition. (In this notation, the vertical line does not denote division).

For example, we might want to know the probability of a person getting a parking ticket given that a person did not put any money in a parking meter. Or a medical researcher might be interested in the probability of a patient developing heart disease given that the patient is a smoker.

If the occurrence of one event affects the probability of occurrence for another event, we say that the events are dependent; otherwise, the events are independent. Dependent events are events where the occurrence of one event affects the probability of occurrence of another event. Independent events are events where the probability of occurrence of one event is not affected by the occurrent of another event. The dependence of events has important implications in many fields such as marketing, engineering, psychology, and medicine.

There are several ways to use conditional probabilities in data science applications.

Conditional probability can be defined as follows:

P(A|B)=P(AandB)P(B), where P(B)0

When assessing the conditional probability of P(A|B), if the two events are independent, this indicates that Event A is not affected by the occurrence of Event B, so we can write that P(A|B)=P(A) for independent events.

If we determine that the P(A|B) is not equal to P(A), this indicates that the events are dependent.

P(A|B)=P(A) implies independent events, where P(B)0.

P(A|B)P(A) implies dependent events.

Probability of At Least One

The probability of at least one occurrence of an event is often of interest in many data science applications. For example, a doctor might be interested to know the probability that at least one surgery to be performed this week will involve an infection of some type.

The phrase “at least one” implies the condition of one or more successes. From a sample space perspective, one or more successes is the complement of “no successes.” Using the complement rule discussed earlier, we can write the following probability formula:

P(at least one success)=1P(no successes)

As an example, we can find the probability of rolling a die 3 times and obtaining at least one four on any of the rolls. This can be calculated by first finding the probability of not observing a four on any of the rolls and then subtracting this probability from 1. The probability of not observing a four on a roll of the die is 5/6. Thus, the probability of rolling a die 3 times and obtaining at least one four on any of the rolls is 1(56)3=0.421.

Bayes’ Theorem

Bayes’ Theorem is a statistical technique that allows for the revision of probability estimates based on new information or evidence that allows for more accurate and efficient decision-making in uncertain situations. Bayes’ Theorem is often used to help assess probabilities associated with medical diagnoses such as the probability a patient will develop cancer based on test screening results. This can be important in medical analysis to help assess the impact of a false positive, which is the scenario where the patient does not have the ailment but the screening test gives a false indication that the patient does have the ailment.

Bayes’ Theorem allows the calculation of the conditional probability P(A|B). There are several forms of Bayes’ Theorem, as shown:

P(A|B)=P(A)·P(B|A)P(B)P(A|B)=P(A)·P(B|A)P(A)·P(B|A)+P(A')·P(B|A')