Statistics IUnit 612 min read

Bivariate Data & Probability: Joint, Marginal & Conditional Distributions

Unit 6 of Statistics I explores how two random variables interact using joint, marginal, and conditional probability distributions—key tools for analyzing real-world data relationships like customer spending patterns or machine failure rates.

TAKEAWAYS:

  • Joint distributions combine two variables into a single probability table (e.g., P(X=x, Y=y)), while marginal distributions extract probabilities for one variable alone.
  • Conditional probability (P(X|Y)) answers "what if?" questions (e.g., "What’s the chance of a Daraz order failing if delivery is late?").
  • Independence means two variables don’t influence each other (e.g., P(X|Y) = P(X)), a critical assumption in many statistical models.
  • Real-world applications include fraud detection (Khalti transaction patterns), supply chain risk (NTC network failures), and A/B testing (Pathao driver incentives).
  • Worked examples tie theory to Nepal’s tech sector: calculating loan default risks (banks), predicting YouTube ad clicks (global), or analyzing NEPSE stock correlations.

1. Joint Probability Distributions: The Foundation

Joint distributions describe how two random variables co-occur. For example, if X = "customer age group" and Y = "purchase amount on Daraz," the joint table shows P(X=20-30, Y=₹5000-10000).

Definition & Properties

  • Definition: A function f(x,y) that gives the probability of both X=x and Y=y occurring simultaneously.

    • For discrete variables: P(X=x, Y=y) = f(x,y)
    • For continuous variables: P(a ≤ X ≤ b, c ≤ Y ≤ d) = ∫∫_{R} f(x,y) dx dy (double integral over region R).
  • Key Properties:

    1. f(x,y) ≥ 0 for all (x,y).
    2. Sum (discrete) or integral (continuous) over all (x,y) = 1.
    3. Marginal distributions can be derived from joint distributions.

Example: Daraz Order Failures

Suppose Daraz tracks order failures (X) and delivery delays (Y):

| X\Y | Delayed (Y=1) | On-Time (Y=0) |
|-----|----------------|---------------|
| Fail (X=1) | 0.10          | 0.05          |
| Success (X=0) | 0.20      | 0.65          |
  • Question: What’s the probability an order both fails and is delayed? Answer: P(X=1, Y=1) = 0.10 (directly from the table).

Visualizing Joint Distributions

For continuous variables (e.g., X = Ncell data usage, Y = customer complaints), we use contour plots or 3D surfaces. Here’s a simplified 2D heatmap for discrete data:


2. Marginal Distributions: Extracting Single-Variable Probabilities

Marginal distributions "sum out" one variable to focus on a single random variable.

How to Compute

For discrete variables:

  • P(X=x) = Σ_y P(X=x, Y=y) (sum over all y).
  • P(Y=y) = Σ_x P(X=x, Y=y) (sum over all x).

For continuous variables:

  • f_X(x) = ∫ f(x,y) dy (integrate over y).
  • f_Y(y) = ∫ f(x,y) dx (integrate over x).

Example: Ncell Customer Complaints

Using the Daraz table above:

  • Marginal for X (order failure): P(X=1) = P(X=1,Y=1) + P(X=1,Y=0) = 0.10 + 0.05 = 0.15. P(X=0) = 0.20 + 0.65 = 0.85.
  • Marginal for Y (delay): P(Y=1) = 0.10 + 0.20 = 0.30. P(Y=0) = 0.05 + 0.65 = 0.70.

Khalti uses marginal distributions to flag suspicious transactions:

  • Joint: P(Transaction > ₹50k, Location = Kathmandu).
  • Marginal: P(Transaction > ₹50k) (overall fraud risk).
  • If P(Transaction > ₹50k | Location = Kathmandu) >> P(Transaction > ₹50k), Kathmandu transactions are scrutinized.

3. Conditional Probability: "What If?" Scenarios

Conditional probability answers: "Given that Y occurs, what’s the probability of X?" Formula: P(X=x | Y=y) = P(X=x, Y=y) / P(Y=y) (for discrete). For continuous: f_{X|Y}(x|y) = f(x,y) / f_Y(y).

Example: NEPSE Stock Correlations

Suppose X = "NEPSE index change (%)" and Y = "Global market change (%)". Given the joint table:

| X\Y | +5% (Y=1) | -2% (Y=0) |
|-----|-----------|-----------|
| +3% (X=1) | 0.20     | 0.10      |
| -1% (X=0) | 0.10     | 0.60      |
  • Question: If the global market rises 5% (Y=1), what’s the chance NEPSE rises 3% (X=1)? Answer: P(X=1 | Y=1) = P(X=1,Y=1) / P(Y=1) = 0.20 / (0.20 + 0.10) = 0.667.

Visualizing Conditional Probability

For continuous data (e.g., X = YouTube ad clicks, Y = ad duration), use conditional density plots:


4. Independence of Events

Two variables are independent if knowing one doesn’t change the probability of the other: P(X=x | Y=y) = P(X=x) for all x,y.

How to Check Independence

  1. Discrete: P(X=x, Y=y) = P(X=x) * P(Y=y) for all x,y.
  2. Continuous: f(x,y) = f_X(x) * f_Y(y) for all x,y.

Example: Pathao Driver Incentives

Pathao tests if X = "driver bonus" and Y = "trip completion time" are independent.

  • Joint data (simplified):
    | X\Y | ≤10 mins (Y=1) | >10 mins (Y=0) |
    |-----|----------------|----------------|
    | Bonus (X=1) | 0.30          | 0.10           |
    | No Bonus (X=0) | 0.10      | 0.50           |
    
  • Check independence: P(X=1,Y=1) = 0.30 vs. P(X=1)*P(Y=1) = (0.40)*(0.40) = 0.16. Since 0.30 ≠ 0.16, not independent → bonuses affect trip times.
graph LR
  A["P(X=x, Y=y)"] -- Independent? --> B["P(X=x) * P(Y=y)"]
  B -- Equal? --> C["Yes: Independent"]
  B -- Not Equal? --> D["No: Dependent"]

NTC assumes independence between:

  • X = "Power outage in Kathmandu" (rare, P(X)=0.05).
  • Y = "Network failure in Pokhara" (rare, P(Y)=0.03). If independent, joint failure probability: P(X,Y) = 0.05 * 0.03 = 0.0015 (0.15%). But if dependent (e.g., same storm causes both), P(X,Y) could be higher.

5. Comparing Distributions: A Summary Table

Type Formula When to Use Example
Joint P(X=x, Y=y) or f(x,y) Both variables’ combined probability. Daraz order failures and delays.
Marginal P(X=x) = Σ P(X=x,Y=y) Probability of one variable alone. Overall Daraz failure rate.
Conditional `P(X Y) = P(X,Y)/P(Y)` Probability of X given Y.
Independent P(X,Y) = P(X)*P(Y) Check if variables are unrelated. Pathao bonuses not affecting trips.

6. Worked Example: Bank Loan Defaults

Scenario: A bank in Nepal uses two variables to assess loan defaults:

  • X = "Customer credit score" (High/Low).
  • Y = "Loan default" (Yes/No). Joint probabilities:
| X\Y | Default (Y=1) | No Default (Y=0) |
|-----|---------------|------------------|
| High (X=1) | 0.05          | 0.40             |
| Low (X=0)  | 0.15          | 0.40             |

Questions:

  1. What’s the probability a customer defaults? Answer: P(Y=1) = 0.05 + 0.15 = 0.20 (20% default rate).
  2. What’s the probability a customer has a high score and defaults? Answer: P(X=1,Y=1) = 0.05.
  3. If a customer has a low score, what’s the chance they default? Answer: P(Y=1|X=0) = 0.15 / (0.15 + 0.40) = 0.273 (27.3%).

Business Insight:

  • The bank can target high-score customers (lower default risk) or offer stricter terms to low-score customers.
  • Independence check: P(X=1,Y=1) = 0.05 vs. P(X=1)*P(Y=1) = 0.45 * 0.20 = 0.09. Since 0.05 ≠ 0.09, credit score and defaults are dependent.

7. Common Pitfalls & Misconceptions

  1. Assuming Independence: Many students assume variables are independent unless told otherwise. Always check!
    • Example: In the loan data, assuming independence would lead to incorrect risk assessments.
  2. Confusing Marginal and Conditional:
    • Marginal: P(X) (total probability).
    • Conditional: P(X|Y) (probability given Y).
  3. Joint Probability ≠ Sum of Marginals:
    • P(X,Y) ≠ P(X) + P(Y) (unless X and Y are mutually exclusive, which is rare in bivariate data).

## In the Real World

  1. eSewa & Khalti Fraud Detection:

    • Idea Used: Conditional probability (P(Fraud | Transaction Amount > ₹50k)).
    • How: Joint distributions of transaction amounts and locations help flag anomalies. For example, if P(Fraud | Location = Kathmandu) = 0.05 but P(Fraud) = 0.01, Kathmandu transactions are flagged for review.
  2. Pathao Driver Performance:

    • Idea Used: Joint and marginal distributions of trip times and driver bonuses.
    • How: Pathao analyzes whether drivers with bonuses complete trips faster. If P(Completion ≤ 10 mins | Bonus = Yes) > P(Completion ≤ 10 mins), bonuses are effective.
  3. NTC Network Outages:

    • Idea Used: Independence testing between power outages and network failures.
    • How: NTC checks if P(Network Failure | Power Outage) > P(Network Failure). If dependent, they invest in backup power for data centers.
  4. YouTube Ad Targeting:

    • Idea Used: Conditional distributions of ad clicks given user demographics.
    • How: YouTube calculates P(Click | Age = 18-24, Location = Nepal) to optimize ad placement. If clicks are higher for this group, ads are shown more frequently to them.
  5. NEPSE Stock Analysis:

    • Idea Used: Joint distributions of NEPSE and global market movements.
    • How: Investors use P(NEPSE Rise | Global Rise) to decide whether to buy/sell stocks. If this probability is high, they assume NEPSE moves with global markets.

## Exam Tip

  1. Always Start with the Joint Table:

    • Most exam questions provide a joint probability table. Memorize how to extract marginals and conditionals from it.
  2. Check Independence Explicitly:

    • If asked whether two variables are independent, always verify using P(X,Y) = P(X)P(Y). Never assume!
  3. Units and Interpretation:

    • For conditional probabilities, always interpret the result in plain language. For example:
      • P(X|Y) = 0.7 → "70% of cases where Y occurs also have X."
  4. Real-World Applications:

    • Exams often ask for applications (e.g., "How would a bank use conditional probability?"). Link theory to Nepal’s tech sector (eSewa, Khalti, NTC, etc.).
  5. Common Exam Questions:

    • Definition-based: "Define marginal probability distribution" (1 mark).
    • Calculation-based: Given a joint table, compute P(X|Y) or check independence (3-5 marks).
    • Application-based: "A factory has three machines... What’s the probability a defective item comes from Machine 1?" (5-8 marks).
  6. Graphs Are Your Friends:

    • Draw joint tables, marginal pie charts, and conditional bar plots in exams. Visuals help clarify your reasoning.

## Practice Questions (Exam-Style)

  1. Short Answer:

    • Define conditional probability distribution. Write its properties for discrete variables.
  2. Calculation:

    • Given the joint distribution of X (student gender: Male/Female) and Y (passes exam: Yes/No):
      | X\Y | Pass (Y=1) | Fail (Y=0) |
      |-----|------------|------------|
      | Male (X=1) | 0.30       | 0.10       |
      | Female (X=0) | 0.25    | 0.35       |
      
      • Compute P(Fail | Female).
      • Are X and Y independent? Justify.
  3. Application:

    • A hospital tracks X (patient smoker: Yes/No) and Y (readmitted: Yes/No). Given:
      • P(X=Yes) = 0.4, P(Y=Yes) = 0.2, P(X=Yes, Y=Yes) = 0.15.
      • What’s the probability a patient is readmitted given they smoke?
      • Interpret the result for hospital policies.

## Key Formulas to Memorize

Concept Formula
Joint Probability P(X=x, Y=y) or f(x,y)
Marginal Probability P(X=x) = Σ P(X=x,Y=y)
Conditional Probability `P(X=x
Independence Check P(X,Y) = P(X)P(Y)
Continuous Joint PDF f_{X,Y}(x,y) = ∫∫ f(x,y) dx dy = 1

## Final Visual Summary

mindmap
  root((Bivariate Distributions))
    Joint
      Definition: P(X=x, Y=y)
      Example: Daraz order failures
    Marginal
      Definition: Sum/Integrate out one variable
      Example: Ncell complaint rates
    Conditional
      Definition: P(X|Y) = P(X,Y)/P(Y)
      Example: NEPSE global correlation
    Independence
      Definition: P(X,Y) = P(X)P(Y)
      Example: Pathao driver bonuses
      Test: Multiply marginals vs. joint

Based on the TU BSc CSIT syllabus for Statistics I (STA169), unit 6.

Discussion

Loading…