返回题库

正方形与圆内的均匀采样

Uniform Sampling in a Square and Circle

专题
Statistics / 统计
难度
L4

题目详情

(a) 如何用两个相互独立的均匀样本 U1,U2U(0,1)U_1,U_2\sim U(0,1) 生成一个落在正方形内的均匀点?

(b) 如何用它们生成单位圆内的均匀点?

(c) 只用一个均匀样本能否生成圆内的均匀点?

英文原题

(a) How can you use two independent uniform samples U1,U2U(0,1)U_1, U_2 \sim U(0,1) to generate a point uniformly inside a square?

(b) How can you use them to generate a point uniformly inside a unit circle?

(c) Can you generate a point uniformly inside a circle with only one uniform sample?

解析

(a) 直接取点 (U1,U2)(U_1,U_2),它在单位正方形 [0,1]2[0,1]^2 上均匀。

(b) 一种常用方法是极坐标变换:取

Θ=2πU1,R=U2,\Theta=2\pi U_1,\quad R=\sqrt{U_2},

(RcosΘ,RsinΘ)(R\cos\Theta, R\sin\Theta) 在单位圆盘内均匀。

(也可用拒绝采样:先生成 (2U11,2U21)(2U_1-1,2U_2-1)[1,1]2[-1,1]^2 上均匀,若落在圆外则重抽。)

(c) 可以。在理论上,一个 UU(0,1)U\sim U(0,1) 含有无限位随机性,可以把其二进制展开的奇偶位拆成两个独立的 U(0,1)U(0,1)(除去一组测度为 0 的二进制表示不唯一点),从而再用 (b) 的方法生成圆内均匀点。


英文解析

(a) Directly sample a point (U1,U2)(U_1,U_2), which is uniformly distributed on the unit square [0,1]2[0,1]^2.

(b) A common method is a polar coordinate transformation: take
Θ=2πU1,R=U2,\Theta=2\pi U_1,\quad R=\sqrt{U_2},
Then (RcosΘ,RsinΘ)(R\cos\Theta, R\sin\Theta) is uniformly distributed within the unit disk.

(Alternatively, use rejection sampling: generate (2U11,2U21)(2U_1-1,2U_2-1) uniformly on [1,1]2[-1,1]^2, and resample if it falls outside the circle.)

(c) Yes. In theory, a UU(0,1)U\sim U(0,1) contains infinite bits of randomness; its binary expansion's even and odd bits can be split into two independent U(0,1)U(0,1) (excluding a set of measure zero of non-unique binary representations), allowing the method in (b) to be used to generate a uniform point inside the circle.