PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Statistics & Math/Microsoft

Compute P(Bag B | red) via Bayes

Last updated: Mar 29, 2026

Quick Overview

This question evaluates understanding of Bayes' rule and conditional probability by requiring computation of the posterior probability that a particular bag was chosen given a red draw.

  • easy
  • Microsoft
  • Statistics & Math
  • Data Scientist

Compute P(Bag B | red) via Bayes

Company: Microsoft

Role: Data Scientist

Category: Statistics & Math

Difficulty: easy

Interview Round: Technical Screen

Three bags contain red (r) and green (g) balls: - Bag A: 4 r, 6 g - Bag B: 6 r, 4 g - Bag C: 3 r, 7 g Process: pick a bag uniformly at random, then draw one ball from that bag. Given the drawn ball is red, compute the posterior probability that it came from Bag B, i.e., P(B | red). Show all steps using Bayes’ rule. Follow-up: if instead the bag is chosen with probabilities P(A)=0.2, P(B)=0.5, P(C)=0.3, recompute P(B | red) and explain the intuition for how the prior changes the result.

Quick Answer: This question evaluates understanding of Bayes' rule and conditional probability by requiring computation of the posterior probability that a particular bag was chosen given a red draw.

Related Interview Questions

  • Choose Classification Metrics Under Asymmetric Costs - Microsoft (medium)
  • Use confusion matrix to choose model metric - Microsoft (easy)
  • Compute sample size and analyze A/B results - Microsoft (medium)
  • Test classifier difference with McNemar's test - Microsoft (medium)
Microsoft logo
Microsoft
Oct 13, 2025, 9:49 PM
Data Scientist
Technical Screen
Statistics & Math
4
0

Bayes' Rule: Posterior Probability of the Chosen Bag

Setup

  • There are three bags containing red (r) and green (g) balls:
    • Bag A: 4 r, 6 g (10 total)
    • Bag B: 6 r, 4 g (10 total)
    • Bag C: 3 r, 7 g (10 total)
  • Process: Pick a bag at random, then draw one ball from that bag.
  • Event R: the drawn ball is red.

Tasks

  1. With a uniform prior over bags (P(A)=P(B)=P(C)=1/3), compute P(B | R) using Bayes’ rule. Show all steps.
  2. Follow-up: If instead P(A)=0.2, P(B)=0.5, P(C)=0.3, recompute P(B | R). Explain the intuition for how changing the prior affects the result.

Assume a single draw from the selected bag (replacement does not matter when drawing only once).

Solution

Show

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Statistics & Math•More Microsoft•More Data Scientist•Microsoft Data Scientist•Microsoft Statistics & Math•Data Scientist Statistics & Math
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.