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?
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
How to Approach This
- Define your hypotheses (H0 and H1) clearly before performing any test.
- Calculate required sample size BEFORE running an experiment, using power analysis.
- Remember the Central Limit Theorem: sample means become approximately normal with large n.
- Watch for Simpson's paradox. Always segment data by key dimensions.
- 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 QuestionsSample Answer
Clarify
Original dataset with distinct rows. A bootstrap sample draws times uniformly with replacement. We want the expected number of distinct original rows in the sample, as a fraction of ....
Approach
Indicators again: where if row is drawn at least once. Each row is missed on every draw with probability , independently across draws....