Compute expectations and test fairness for coin flips

Quick Overview

This question evaluates proficiency in probability and statistical inference, specifically expectation and variance of Bernoulli variables, properties of the geometric distribution, and p-value reasoning for hypothesis testing.

Compute expectations and test fairness for coin flips

Company: Snapchat

Role: Data Scientist

Category: Statistics & Math

Difficulty: easy

Interview Round: Technical Screen

You are analyzing repeated flips of a (possibly unfair) coin. ## Setup Let the probability of Heads be \(p\) (unknown in general). Assume flips are independent and identically distributed. ## Part A — Expected value for an unfair coin Define a random variable \(X\) for a single flip: - \(X = 1\) if the flip is Heads - \(X = 0\) if the flip is Tails 1. Compute \(\mathbb{E}[X]\). 2. (Optional but common follow-up) Compute \(\mathrm{Var}(X)\). ## Part B — “Getting a 3” using a geometric distribution Now flip the coin repeatedly until the first Head appears. Let \(T\) be the number of flips needed to get the first Head (so \(T\in\{1,2,3,\dots\}\)). 1. Write the distribution of \(T\) and identify it. 2. Compute \(\mathbb{P}(T=3)\) in terms of \(p\). 3. For a fair coin (\(p=0.5\)), compute the numerical value of \(\mathbb{P}(T=3)\). 4. Compute \(\mathbb{E}[T]\). ## Part C — Is the coin fair? (p-value reasoning) Suppose you ran this “flip-until-first-Head” experiment once and observed \(T=3\). You want to test: - \(H_0: p=0.5\) (fair coin) - \(H_1: p<0.5\) (coin is biased toward Tails; Heads are rarer) 1. Propose a reasonable p-value for this one observation using an appropriate tail probability under \(H_0\). 2. Briefly explain what is and is not learnable from a single observation, and what you would do instead to make the test meaningful (e.g., repeat the experiment \(n\) times).

Quick Answer: This question evaluates proficiency in probability and statistical inference, specifically expectation and variance of Bernoulli variables, properties of the geometric distribution, and p-value reasoning for hypothesis testing.

|Home/Statistics & Math/Snapchat
Snapchat logo
Snapchat
Sep 1, 2025, 12:00 AM
easyData ScientistTechnical ScreenStatistics & Math
12
0

You are analyzing repeated flips of a (possibly unfair) coin.

Setup

Let the probability of Heads be pp (unknown in general). Assume flips are independent and identically distributed.

Part A — Expected value for an unfair coin

Define a random variable XX for a single flip:

  • X=1X = 1 if the flip is Heads
  • X=0X = 0 if the flip is Tails
  1. Compute E[X]\mathbb{E}[X] .
  2. (Optional but common follow-up) Compute Var(X)\mathrm{Var}(X) .

Part B — “Getting a 3” using a geometric distribution

Now flip the coin repeatedly until the first Head appears.

Let TT be the number of flips needed to get the first Head (so T{1,2,3,}T\in\{1,2,3,\dots\}).

  1. Write the distribution of TT and identify it.
  2. Compute P(T=3)\mathbb{P}(T=3) in terms of pp .
  3. For a fair coin ( p=0.5p=0.5 ), compute the numerical value of P(T=3)\mathbb{P}(T=3) .
  4. Compute E[T]\mathbb{E}[T] .

Part C — Is the coin fair? (p-value reasoning)

Suppose you ran this “flip-until-first-Head” experiment once and observed T=3T=3.

You want to test:

  • H0:p=0.5H_0: p=0.5 (fair coin)
  • H1:p<0.5H_1: p<0.5 (coin is biased toward Tails; Heads are rarer)
  1. Propose a reasonable p-value for this one observation using an appropriate tail probability under H0H_0 .
  2. Briefly explain what is and is not learnable from a single observation, and what you would do instead to make the test meaningful (e.g., repeat the experiment nn times).
Loading comments...