Expected Steps for a Random Walk to Leave a Band

Last updated: November 29, 2026

Quick Overview

A metric performs a symmetric random walk on the integers, starting at 0 and moving up or down by 1 each step with probability 1/2. What is the expected number of steps until it first reaches +N or -N?

Google
Statistics & Math
Data Scientist
Google
November 29, 2026
Data Scientist
Onsite
Statistics & Math
Medium

0

0

0 solved


A metric performs a symmetric random walk on the integers, starting at 0 and moving up or down by 1 each step with probability 1/2. What is the expected number of steps until it first reaches +N or -N?

Random walk exit times are a common Google onsite step up from simple expectations. The interviewer checks first-step analysis on a boundary value problem, or a martingale argument, and the scaling intuition that distance grows like the square root of time.

What the Interviewer Expects
  • Set up E_k = 1 + (E_{k-1} + E_{k+1})/2 with boundaries
  • Solve the quadratic to get E_k = N^2 - k^2
  • Answer N^2 from the center
  • Give the martingale S_n^2 - n argument
  • Connect to sqrt(n) scaling of random walks
Key Topics to Cover
random walks
martingales
optional stopping
boundary value problems
diffusion scaling
How to Approach This
  1. Define your hypotheses (H0 and H1) clearly before performing any test.
  2. Calculate required sample size BEFORE running an experiment, using power analysis.
  3. Remember the Central Limit Theorem: sample means become approximately normal with large n.
  4. Watch for Simpson's paradox. Always segment data by key dimensions.
  5. Distinguish between statistical significance and practical significance.
Possible Follow-up Questions
  • What is the expected exit time from an asymmetric band, from 0 to reach +a or -b?
  • How does a drift change the expected exit time?
  • What is the probability of hitting +N before -N from position k?
  • How does this relate to alerting thresholds on noisy metrics?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Browse Statistics Questions
Sample Answer
Clarify

Simple symmetric random walk S0=0S_0 = 0, steps ±1\pm 1 with probability 1/21/2. Stop at T=min⁡{n:∣Sn∣=N}T = \min\{n : |S_n| = N\}. We want E[T]E[T], and more generally EkE_k starting from position kk....

Approach

Two methods. First-step analysis gives a second order recurrence with boundaries E±N=0E_{\pm N} = 0. Alternatively, Mn=Sn2−nM_n = S_n^2 - n is a martingale, and optional stopping gives E[ST2]=E[T]E[S_T^2] = E[T]....


Submit Your Answer
Markdown supported