Register for our webinar

How to Nail your next Technical Interview

1 hour
Loading...
1
Enter details
2
Select webinar slot
*Invalid First Name
*Invalid Last Name
*Invalid Phone Number
By sharing your contact details, you agree to our privacy policy.
Select your webinar time
Step 1
Step 2
Congratulations!
You have registered for our webinar
Oops! Something went wrong while submitting the form.
1
Enter details
2
Select webinar slot
Step 1
Step 2
Confirmed
You are scheduled with Interview Kickstart.
Redirecting...
Oops! Something went wrong while submitting the form.
Our June 2021 cohorts are filling up quickly. Join our free webinar to Uplevel your career
0%
100%

Attend our Free Webinar on How to Nail Your Next Technical Interview

WEBINAR +LIVE Q&A

How To Nail Your Next Tech Interview

Hosted By
Ryan Valles
Founder, Interview Kickstart
Our tried & tested strategy for cracking interviews
How FAANG hiring process works
The 4 areas you must prepare for
How you can accelerate your learnings

Data Science Interview Prep: How to Crack Probability Problems

Posted on 
May 3, 2022
|
by 
Team Interview Kickstart

The Harvard Business Review has described it as “The Sexiest Job of the 21st Century.”

US News consistently ranks it in the Top 3 “Best Technology Jobs,” year after year.

The U.S. Bureau of Labor Statistics forecasts a growth of 28%, or 11.5 Million, for the career through 2026.

Of course, we are talking about the field of Data Science. This career path grants you tremendous influence in shaping the future direction of the business, not to mention a long-term professional trajectory and rewarding compensation. However, the interview process for these positions is challenging, to say the least.

In this article, we will walk you through one of the most common topics that come up in virtually every FAANG Data Science Interview — probability. It will be important for you to understand the ways Probability can pop up in technical interviews to ensure your success throughout the process. 

Whether you are preparing for your first Data Science role or refreshing your skills for the next role, check out our technical interview checklist, interview questions page, and salary negotiation e-book to get interview-ready!

We’ll cover the following topics in this article:

  • How to Approach a Probability Question at a Data Science Interview
  • How to Answer Different Types of Probability Questions at Data Science Interviews

How to Approach a Probability Question at a Data Science Interview

Although the questions posed in a Data Science Interview may take many forms, you can succeed by identifying common fundamentals. In other words, you have to understand the lingo. This strategy of recognizing similar questions and applying the relevant, structured approach to problem-solving takes practice.

When answering a Probability question during an interview, it is important to approach the answer through the following steps:

  1. Recognize the key concept of the question: Is it a Probability question? Don’t be afraid to ask your interviewer clarifying questions!
  2. Structure upfront: Walk your interviewer through the structure you will use to solve the question.
  3. Calculations: Keep actual math as simple as possible and explain why you’re doing it.
  4. Communicate the significance: What is the meaning or impact of the result you calculated? What are some other considerations to keep in mind?

How to Answer Different Types of Probability Questions at Data Science Interviews

At Interview Kickstart, we have simplified Statistical Probability into three buckets to capture the critical concepts that typically come up in interviews:

  • Probability Rules
  • Independent Events
  • Expected Value

Let’s explore each brand of question through an explanation and an example so that you are prepared when these subjects come up in your next Data Science Interview.

Probability Rules: What are the most important rules of probability?

Before discussing the rules, it is helpful to review the Axioms of Probability:

  1. Let Ω be the sample space. P(Ω) = 1.

    In other words: “the probability that something happens equals 1”.
  2. Let A be any event. Then 0 ≤ P(A) ≤ 1

    In other words: “the probability of any event happening is between 0 and 1.”

Now, we can think of a Venn Diagram to visualize the basic rules of probability:

The Addition Rule tells us that:

P(A or B) = P(A) + P(B) – P(A and B)

Looking at our Venn Diagram, we can see that the probability of Event A or Event B occurring is the combined area of both circles. However, if we simply add both circles, we would be including the green wedged area where these circles intersect, also known as A∩B, twice. To account for this, we subtract P(A and B) at the end of the formula.

The Conditional Probability Rule tells us that: 

P(A|B) = P(A and B) / P(B)

This tells us the probability that event A has occurred, given (or conditional on) that event B has occurred. Similarly, we could also say:

P(B|A) = P(A and B) / P(A)

Let’s look at an example:

Consider the collection of Sci-Fi movies released since 1982. Define the event W as a movie is a wide release (>1000 theaters during the opening week) and the event B as a movie is a blockbuster (>$100 million gross revenue). Based on past data, we know the following: 

P(W) = 0.46

P(B) = 0.17

P(W and B) = 0.15

(a) What is the probability that a Sci-Fi movie is a wide release or a blockbuster?

Answer: 

P(W) + P(B) – P(W and B) = 0.46 + 0.17 – 0.15 = 0.48

(b) Given that the movie is a wide release, what is the probability that it is a blockbuster?

Answer: 

P(B|W) = P(B and W) / P(W) = 0.15 / 0.46 = 0.326

Independent Events

Independence occurs when the outcome of one event has no effect on the probability of another event occurring. Mathematically, we can think of this as a special case if and only if the following statements are true:

P(A|B) = P(A)

P(B|A) = P(B)

P(A and B) = P(A) * P(B)

Note: the truth of any of the above statements actually implies the truth of the other two

An easy way to see the behavior of independence events is by thinking of flipping a 2-sided coin twice. The chance of getting heads on the second flip is 0.50. If you then tell me you got heads on the first flip, the probability is still 0.50 for the second film. The information regarding the outcome of the first toss had no effect; therefore, the events of the first toss and the second toss are independent.

Dependence occurs in the inverse case in which the outcome of one event has an effect on the probability of another event. Mathematically, we could say P(A|B) ≠ P(A).

Let’s return to our example of Sci-Fi movies:

(a) Are the events W and B independent? Why or why not?

Answer: Let’s test the mathematical definition of independence. For independence to be true, P(B|W) = P(B). Is this the case?

P(B|W) = 0.326 as calculated in (b). 

P(B|W) 0.17 = P(B)

Learning whether a movie is a wide release changes our beliefs about the probability of a blockbuster. Therefore, W and B are NOT independent.

Expected Value

The mean μ of a discrete random variable X is also known as the expected value. It is denoted by E(X) and is computed by multiplying each value of the random variable by its probability and then adding over the sample space. 

Let’s look at an interview example: 

We have two options for serving ads within Newsfeed. 

  • Option 1: 1 out of every 25 stories, one will be an ad. 
  • Option 2: every story has a 4% chance of being an ad. 

What is the expected number of ads shown in 100 news stories for each option? 

Answer: Option 1 involves a standard Expected Value which we can calculate as

E(ads) = 1/25 * 100 = 4 ads will be shown

Now, let’s calculate the Expected number of ads for Option 2:

E(ads) = 4% * 100 = 4 ads will be shown

Although worded slightly differently as a discrete number of ads in Option 1 vs. a rate in Option 2, the takeaway here is that both options have the same Expected number of ads.

Let’s look at another interview example

There is a game where you are given two fair six-sided dice and asked to roll. If the sum of the dice values equals seven, you win $21. However, you must pay $5 to play each time you roll both dice. Do you play this game?

Answer: Let’s apply the 4-step framework to answering interview questions from the beginning of this post:

1. Recognize the core of the question: This question wants us to calculate the Expected Value of a game that always costs a fixed amount ($5) to play, but provides an opportunity to win a greater amount ($21) with some probability.

2. Structure Upfront: When answering this question, we can think about the sample space of 2 dice to calculate the probability of winning. Then, we will multiply this by the value of winning, less the cost of playing. Let’s write out the possibilities of rolling 1 green and 1 blue dice:

3. Calculations: There are 6 cases where the Sum of the two dice rolls equals 7. So,

P(Sum 7) = 6/36 = ⅙

This means you have a 1/6 chance of winning $21 (and 5/6 of winning $0).

To calculate the Expected Value of the game, we must subtract the $5 cost to play:

E(Game) = ⅙($21) + ⅚($0) - $5 = -$1.50

4. Communicate the Significance: Since the Expected Value of this game is negative (-$1.50), you will lose money on average and should not play this game.

Preparing for a Data Science Interview?

Interview Kickstart’s Data Science Interview Course covers all key data science interview concepts. Bundled into a 13-week curriculum, the course is designed and taught by FAANG instructors to prepare you for all stages of a typical Data Science Interview. We also offer direct coaching and mock interviews.

Interview Kickstart is the leading resource for tech interview prep. Our programs also include career coaching and mock interviews to boost your confidence and help you get interview-ready.

Sign up for our FREE webinar to uplevel your career!

Worried About Failing Tech Interviews?

Attend our webinar on
"How to nail your next tech interview" and learn

Hosted By
Ryan Valles
Founder, Interview Kickstart
Our tried & tested strategy for cracking interviews
How FAANG hiring process works
The 4 areas you must prepare for
How you can accelerate your learnings
Register for Webinar

Recent Articles