Katkat

Sample Points Uniformly from a Unit Disk

WaymoData Scientist · Technical Screen

Last updated

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

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.

Hints

Hint 1

Compare regions with equal area: Consider how much of the disk lies within a chosen distance of the center.

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?