I knew something was off with the naive approach but couldn't articulate it cleanly at first.
Start by explaining the intuitive but incorrect method of picking radius uniformly and angle uniformly, then show why it fails due to non-uniform area distribution. Present the correct method using inverse transform sampling: sample radius with density proportional to r, i.e., r = R * sqrt(U), and angle uniformly. Optionally, mention alternative methods like rejection sampling or using two Gaussian variables.
Pro tip: Emphasize that the probability of a point falling in a region is proportional to its area, so the radial density must be linear in r. This demonstrates deep understanding of probability density transformations, a key skill for ML engineers.
Describe picking radius uniformly from [0, R] and angle uniformly from [0, 2π). Point out that this over-samples the center because the area of an annulus grows with radius, so uniform radius does not yield uniform area density.
Show that for uniform area, the probability density of radius r is proportional to r, i.e., f(r) = 2r/R^2 for 0 ≤ r ≤ R. This comes from the area element dA = r dr dθ.
Compute the CDF F(r) = r^2/R^2 and invert it: r = R * sqrt(U), where U ~ Uniform(0,1). Combine with θ = 2π V, V ~ Uniform(0,1).
Briefly note other valid approaches: rejection sampling (sample in square and reject outside circle) or using two independent standard normal variables and normalizing to radius R.
Compare efficiency: inverse transform is O(1) and exact, rejection sampling may be less efficient but simpler. Relate to ML contexts like sampling from distributions or generating synthetic data.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.