Sample Points Uniformly from a Unit Disk

Read the full interview experience this question came from →

Quick Overview

Derive uniform random sampling inside a unit disk, explain the radial distribution, and compare a polar sampler with rejection sampling.

Sample Points Uniformly from a Unit Disk

Company: Waymo

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

## Sample Points Uniformly from a Unit Disk Write a function that takes the requested number of points, `n`, and returns `n` random two-dimensional points distributed uniformly over the area inside the unit circle centered at the origin. The output is a collection of coordinate pairs. Explain why the sampling rule is uniform over the disk's area. The task does not prescribe a random seed or a fixed sequence of coordinates; many sampled outputs are valid. ### Clarifications Uniformity is over area, rather than over the radius alone or only around the circumference. The input represents a number of requested points. Discuss the empty output when no points are requested. ```hint Compare regions with equal area Consider how much of the disk lies within a chosen distance of the center. ``` ### What a Strong Answer Covers - Generates points inside the radius-one disk and returns the requested number of coordinate pairs. - Explains the radial distribution needed for uniform area coverage. - Distinguishes random sampling from returning one deterministic coordinate list. - States the time and storage cost in terms of the requested number of points. ### Follow-up Questions - Why does choosing a radius uniformly between zero and one concentrate points near the center? - How would rejection sampling from the surrounding square produce another valid uniform sampler?

Overview: Derive uniform random sampling inside a unit disk, explain the radial distribution, and compare a polar sampler with rejection sampling.

Read the full Waymo Data Scientist interview experience this question came from

|Home/Coding & Algorithms/Waymo
Waymo logo
Waymo
Sep 28, 2026
mediumData ScientistTechnical ScreenCoding & Algorithms
0
0

Sample Points Uniformly from a Unit Disk

Write a function that takes the requested number of points, n, and returns n random two-dimensional points distributed uniformly over the area inside the unit circle centered at the origin.

The output is a collection of coordinate pairs. Explain why the sampling rule is uniform over the disk's area. The task does not prescribe a random seed or a fixed sequence of coordinates; many sampled outputs are valid.

Clarifications

Uniformity is over area, rather than over the radius alone or only around the circumference. The input represents a number of requested points. Discuss the empty output when no points are requested.

What a Strong Answer Covers Guidance

  • Generates points inside the radius-one disk and returns the requested number of coordinate pairs.
  • Explains the radial distribution needed for uniform area coverage.
  • Distinguishes random sampling from returning one deterministic coordinate list.
  • States the time and storage cost in terms of the requested number of points.

Follow-up Questions Guidance

  • Why does choosing a radius uniformly between zero and one concentrate points near the center?
  • How would rejection sampling from the surrounding square produce another valid uniform sampler?

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...