用 (x,y) 生成圆盘均匀点
Random point on disk
题目详情
给定 为独立均匀随机数,取值在 。
用它们构造单位圆盘(半径 1)的一个均匀随机点(面积密度常数)。
提示:直角坐标到极坐标;圆面积随半径平方增长。
英文原题
& are two random points selected uniformly between & . Using them, create a point uniformly random in a circle of radius . (uniform means that the probability density is constant)
Hint
Convert Cartesian coordinates to Polar coordinates. And the area of a circle grows with the square of its radius.
解析
取
再输出点
原因:面积元素为 ,要让半径分布与面积匹配,需要 均匀,因此 。
英文解析
Set
and output
The angular variable is uniform on . For a point to be uniform by area in the unit disk, the probability of falling inside radius must be , because the disk area scales as . If is uniform on and , then , so the radial distribution matches area. Therefore this transform gives a uniform point in the disk.