Skip to content
elevatedevco

Careers & Interviews

Probability for interviews

Learn Probability for interviews: 34 practice questions and answers with an interactive quiz — from the offline AI Learning app.

Professional34 questions34 quiz questions

Questions & Answers

Tap a question to reveal its answer. Written for self-study and interview preparation.

What is the difference between independence and mutual exclusivity of two events A and B?

Independence means P(A∩B)=P(A)P(B), i.e., knowing one event gives no information about the other. Mutual exclusivity means P(A∩B)=0, i.e., the events cannot co-occur. Two events with positive probability cannot be both independent and mutually exclusive, because mutual exclusivity makes them maximally dependent (if A occurs, B definitely did not).

State Bayes' theorem and explain the role of the prior, likelihood, and evidence.

Bayes' theorem: P(H|D) = P(D|H)P(H) / P(D), where P(H) is the prior (belief before data), P(D|H) is the likelihood (probability of data given hypothesis), and P(D) is the evidence/marginal likelihood (normalizing constant = Σ P(D|H_i)P(H_i)). The posterior P(H|D) updates the prior in proportion to how well the hypothesis explains the data.

A disease affects 1% of a population. A test has 99% sensitivity and 95% specificity. Given a positive test, what is the probability the person has the disease?

Using Bayes: P(D|+) = (0.99·0.01)/(0.99·0.01 + 0.05·0.99) = 0.0099/(0.0099+0.0495) = 0.0099/0.0594 ≈ 0.1667, about 16.7%. Despite high accuracy, the low base rate makes most positives false positives. This illustrates the base-rate fallacy.

p_d=0.01; sens=0.99; spec=0.95
post = sens*p_d / (sens*p_d + (1-spec)*(1-p_d))
print(round(post,4))  # 0.1667
What is the expected number of coin flips of a fair coin to get the first head?

The number of flips follows a Geometric distribution with success probability p=0.5. Its expectation is 1/p = 1/0.5 = 2. Intuitively, on average you need two flips to see the first head.

Explain the difference between a probability density function (PDF) and a probability mass function (PMF).

A PMF applies to discrete random variables and gives P(X=x), the actual probability of each value, summing to 1. A PDF applies to continuous random variables; f(x) is a density, not a probability—P(X=x)=0 for any point—and probabilities come from integrating f over an interval. The PDF can exceed 1 as long as it integrates to 1.

What is the Law of Total Expectation (tower property)?

E[X] = E[E[X|Y]]: the expected value of X equals the expectation over Y of the conditional expectation of X given Y. It lets you compute E[X] by conditioning on an auxiliary variable and then averaging. A related identity is the Law of Total Variance: Var(X)=E[Var(X|Y)]+Var(E[X|Y]).

State the Central Limit Theorem and one key condition for it to hold.

The CLT states that the standardized sum (or mean) of n i.i.d. random variables with finite mean μ and finite variance σ² converges in distribution to a standard normal as n→∞: (X̄-μ)/(σ/√n) → N(0,1). The key condition is finite variance (and i.i.d. sampling). Distributions with infinite variance, like Cauchy, do not obey the classic CLT.

What is the variance of a Bernoulli(p) random variable, and at what p is it maximized?

Var(X)=p(1-p). It is maximized at p=0.5, giving variance 0.25. The variance is zero at the deterministic extremes p=0 and p=1.

You roll two fair dice. What is the probability the sum is 7?

There are 36 equally likely outcomes. Sum 7 occurs for (1,6),(2,5),(3,4),(4,3),(5,2),(6,1) = 6 outcomes. So P = 6/36 = 1/6. Seven is the most likely sum for two dice.

Explain the difference between covariance and correlation.

Covariance Cov(X,Y)=E[(X-μ_X)(Y-μ_Y)] measures the joint linear variation but its magnitude depends on the units/scales of X and Y. Correlation ρ = Cov(X,Y)/(σ_X σ_Y) is the scale-free, unitless normalization bounded in [-1,1]. Zero covariance/correlation implies no linear relationship but not independence.

What does it mean for two random variables to be conditionally independent given a third?

X and Y are conditionally independent given Z if P(X,Y|Z)=P(X|Z)P(Y|Z) for all values of Z. Equivalently, once Z is known, Y provides no additional information about X. Note conditional independence neither implies nor is implied by marginal independence.

In the Monty Hall problem, should you switch doors after the host reveals a goat, and what is the win probability?

Yes, you should switch. Switching wins with probability 2/3, while staying wins with probability 1/3. The host's action of always revealing a goat behind a non-chosen door transfers the 2/3 probability mass to the remaining unopened door.

What is the memoryless property, and which distributions have it?

A distribution is memoryless if P(X>s+t | X>s)=P(X>t): past waiting provides no information about future waiting. The exponential distribution is the only continuous distribution with this property, and the geometric distribution is its only discrete counterpart.

Given a Poisson process with rate λ events per unit time, what is the distribution of inter-arrival times?

Inter-arrival times are i.i.d. Exponential(λ) with mean 1/λ. The number of events in any interval of length t is Poisson(λt), and the time to the k-th event follows a Gamma(k, λ) distribution.

What is the expected value and variance of a continuous Uniform(a,b) distribution?

Mean = (a+b)/2 and Variance = (b-a)²/12. The mean is the midpoint, and variance grows with the square of the interval width.

Explain the difference between MLE and MAP estimation from a probabilistic standpoint.

MLE maximizes the likelihood P(D|θ), choosing parameters that make the observed data most probable, with no prior. MAP maximizes the posterior P(θ|D) ∝ P(D|θ)P(θ), incorporating a prior P(θ) which acts as regularization. As the data grows, MAP converges to MLE because the likelihood dominates the prior.

What is the probability that in a group of 23 people at least two share a birthday (birthday paradox)?

Approximately 50.7%. Compute the complement: P(all distinct) = 365!/((365-23)!·365²³) ≈ 0.493, so P(at least one match) ≈ 1 - 0.493 ≈ 0.507. The surprise comes from there being C(23,2)=253 pairs.

from math import prod
p_distinct = prod((365-i)/365 for i in range(23))
print(round(1-p_distinct,3))  # 0.507
What is a confidence interval, and is it correct to say there is a 95% probability the parameter lies in a particular 95% CI?

A 95% confidence interval is a random interval constructed so that, over repeated sampling, 95% of such intervals would contain the true fixed parameter. It is incorrect (in the frequentist sense) to say a particular computed interval has a 95% probability of containing the parameter—the parameter is fixed and the interval either does or does not contain it. The 95% refers to the long-run coverage of the procedure.

Two players alternately flip a fair coin; the first to get heads wins. What is the probability the first player wins?

P(first wins) = 1/2 + (1/2)²·(1/2) + ... = sum over odd flips = (1/2)/(1-1/4) = 2/3. The first player wins with probability 2/3 because they get the first chance each round.

What is the difference between a Type I and Type II error?

A Type I error (false positive) is rejecting a true null hypothesis; its probability is α, the significance level. A Type II error (false negative) is failing to reject a false null hypothesis; its probability is β, and power = 1-β. Lowering α typically raises β for fixed sample size.

If X ~ N(0,1), what is the distribution of X², and what is its mean?

X² follows a Chi-squared distribution with 1 degree of freedom, χ²(1). Its mean equals the degrees of freedom, which is 1, and its variance is 2. More generally, the sum of k independent squared standard normals is χ²(k).

Explain the difference between sampling with and without replacement in terms of the resulting distributions.

Sampling with replacement keeps draws independent and identically distributed, so counts of successes follow a Binomial distribution. Sampling without replacement makes draws dependent (the population shrinks), so counts follow a Hypergeometric distribution. For large populations relative to sample size, the hypergeometric approximates the binomial.

What is the expected number of draws to collect all n coupons in the coupon collector problem?

The expectation is n·H_n = n·(1 + 1/2 + ... + 1/n) ≈ n·(ln n + γ), where γ≈0.577 is the Euler-Mascheroni constant. It grows like n ln n, so collecting the last few coupons dominates the time.

def coupon_expectation(n):
    return n*sum(1/k for k in range(1,n+1))
print(round(coupon_expectation(10),2))  # ~29.29
What is the difference between a marginal, joint, and conditional distribution?

The joint distribution P(X,Y) gives probabilities over all combinations of X and Y. The marginal P(X)=Σ_y P(X,Y) (or integral) collapses out the other variable. The conditional P(X|Y)=P(X,Y)/P(Y) gives the distribution of X for a fixed value of Y. Together they satisfy the chain rule P(X,Y)=P(X|Y)P(Y).

For independent X and Y, how do means and variances of X+Y combine, and what about X-Y?

For any X,Y: E[X±Y]=E[X]±E[Y]. For independent (or uncorrelated) variables, Var(X+Y)=Var(X-Y)=Var(X)+Var(Y); variances add for both sum and difference because the covariance term is zero. With correlation, Var(X±Y)=Var(X)+Var(Y)±2Cov(X,Y).

What is the moment generating function (MGF) and why is it useful?

The MGF is M_X(t)=E[e^{tX}]. Its n-th derivative at t=0 gives the n-th raw moment, E[X^n]=M_X^{(n)}(0). MGFs are useful because they uniquely determine a distribution (when they exist in a neighborhood of 0) and the MGF of a sum of independent variables is the product of their MGFs, simplifying convolution proofs.

You have a biased coin with unknown bias. How can you simulate a fair coin using von Neumann's trick?

Flip the biased coin twice. Map HT to 'heads' and TH to 'tails'; if you get HH or TT, discard and repeat. Since P(HT)=p(1-p)=P(TH), the two outcomes are equally likely regardless of the bias p, yielding a fair result.

import random
def fair_flip(p):
    while True:
        a,b = random.random()<p, random.random()<p
        if a!=b:
            return a  # True/False equally likely
What is Simpson's paradox, and why does it matter for data analysis?

Simpson's paradox occurs when a trend that appears in aggregated data reverses or disappears when the data is split into subgroups, due to a confounding variable. For example, a treatment can look worse overall yet better within every subgroup. It matters because naive aggregation can mislead causal conclusions; proper stratification or causal adjustment is needed.

What is the relationship between the Poisson and Binomial distributions?

The Poisson(λ) distribution is the limit of Binomial(n,p) as n→∞ and p→0 with np=λ held constant (law of rare events). This makes Poisson a good approximation for many trials with small per-trial success probability. Both have the count interpretation, but Poisson has equal mean and variance (both λ), whereas Binomial has variance np(1-p)<np.

Define entropy of a discrete random variable and state when it is maximized.

Entropy H(X) = -Σ p(x) log p(x) measures the average uncertainty (in bits if log base 2) of a random variable. For a variable with k possible outcomes, entropy is maximized by the uniform distribution, giving H = log k. It is zero when the outcome is deterministic.

What is the KL divergence between two distributions and is it a metric?

KL divergence D_KL(P||Q)=Σ P(x) log(P(x)/Q(x)) measures how one distribution P differs from a reference Q, in expected extra bits when coding P with Q's optimal code. It is non-negative and zero iff P=Q, but it is NOT a metric: it is asymmetric (D_KL(P||Q)≠D_KL(Q||P)) and violates the triangle inequality.

A stick of length 1 is broken at two uniformly random points. What is the probability the three pieces can form a triangle?

The probability is 1/4. The three pieces form a triangle iff no piece exceeds 1/2 (triangle inequality). Modeling the two break points uniformly, the favorable region in the unit square has area 1/4.

import random
def trial():
    a,b = sorted([random.random(), random.random()])
    p1,p2,p3 = a, b-a, 1-b
    return max(p1,p2,p3) < 0.5
print(sum(trial() for _ in range(10**6))/10**6)  # ~0.25
What is the expected value of the maximum of two independent Uniform(0,1) random variables?

For M=max(U1,U2), the CDF is P(M≤m)=m², so the PDF is 2m on [0,1]. Then E[M]=∫₀¹ m·2m dm = 2/3. More generally, the expected maximum of n i.i.d. Uniform(0,1) is n/(n+1).

Explain the difference between a frequentist and a Bayesian interpretation of probability.

The frequentist view defines probability as the long-run relative frequency of an event over many repetitions; parameters are fixed unknown constants. The Bayesian view treats probability as a degree of belief that can be updated with data via Bayes' theorem; parameters have prior and posterior distributions. This leads to different tools: confidence intervals (frequentist) vs credible intervals (Bayesian).

Put it into practice with AI Learning

This topic — and hundreds more — comes from our free, offline AI Learning app. Practice Q&A, quizzes and cheat sheets anywhere, no account needed.

  • Free
  • No account
  • Works offline
Coming soon toGoogle Play