Interview Q&A / Data Science

BeginnerQuick answer1 min readUpdated 3 Oct 2026

How do you calculate conditional probability from a two-way table?

SHORT ANSWER

P(A given B) is the count of A-and-B divided by the count of B. You restrict attention to the rows or columns where B is true and compute the share there. P(A given B) is not the same as P(B given A).

Explain it simply

"Given B" means we shrink the universe to only those cases where B happened. Then count what fraction of that smaller group also has A.

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

Example

A college has 100 students in a placement drive.

PlacedNot placedTotal
Boys213960
Girls162440
Total3763100
  • P(placed) = 37 / 100 = 0.37
  • P(placed | girl) = 16 / 40 = 0.40
  • P(girl | placed) = 16 / 37 = 0.432

The two conditionals answer different questions and use different denominators.

python
placed_girl, girls, placed = 16, 40, 37
print(placed_girl / girls)            # 0.4
print(round(placed_girl / placed, 3)) # 0.432

What to say in the interview

"For conditional probability I restrict to the given condition and use its count as the denominator. Here, among girls the placement rate is 40%, but only 43% of placed students are girls. These are different numbers, and mixing them up is a common error."

Common mistakes

  • Dividing by the grand total instead of the total of the condition.

#conditional-probability#probability#contingency-table

Related questions

Practise more Data Science questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Data Science quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.