Fraction of Distinct Training Rows in a Bootstrap Sample

Last updated: November 29, 2026

Quick Overview

When you bootstrap a training set of n rows (draw n rows with replacement), what fraction of the original rows appear at least once on average, and how is this used for out-of-bag evaluation?

Google
Statistics & Math
Machine Learning Engineer
Google
November 29, 2026
Machine Learning Engineer
Technical Screen
Statistics & Math
Medium

0

0

0 solved


When you bootstrap a training set of n rows (draw n rows with replacement), what fraction of the original rows appear at least once on average, and how is this used for out-of-bag evaluation?

Google ML engineer screens often include a short probability question tied to model training. This one checks the occupancy calculation, the limit 1 - 1/e, and the connection to out-of-bag error in bagged models like random forests.

What the Interviewer Expects
  • Use indicator for each row being chosen at least once
  • Compute P(row missed) = (1 - 1/n)^n
  • Take the limit 1/e, so about 63.2% distinct
  • Give expected distinct count n(1 - (1 - 1/n)^n)
  • Explain out-of-bag rows (about 36.8%) as a validation set
Key Topics to Cover
bootstrap
occupancy problems
linearity of expectation
out-of-bag error
limits
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 variance of the number of distinct rows?
  • If you draw m rows with replacement instead of n, what fraction is distinct?
  • Why is the out-of-bag error estimate slightly pessimistic?
  • How does this relate to caching: expected distinct keys in k random requests?
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

Original dataset with nn distinct rows. A bootstrap sample draws nn times uniformly with replacement. We want the expected number of distinct original rows in the sample, as a fraction of nn....

Approach

Indicators again: D=∑iIiD = \sum_i I_i where Ii=1I_i = 1 if row ii is drawn at least once. Each row is missed on every draw with probability (1−1/n)(1 - 1/n), independently across draws....


Submit Your Answer
Markdown supported