In general, the conversion function between two distributions and is,
By integration on both side, we have
We are going to show a generation of uniform distribution on a Disk first. We set the distribution be a uniform distribution form . From the polar coordinate, we have,
the right side is the unit area element in polar coordinate. We can set , , thus,
in Mathematica,
n=10000; θ=RandomReal[{0,2 pi},n]; f[x_]:=Sqrt[x]; r=Table[f[RandomReal[{0,1}]],{i,1,n}]; disk=Table[r[[i]]{Cos[θ[[i]]],Sin[θ[[i]]]},{i,1,n}] ListPlot[disk]
Similarly, For a uniform sphere,
Thus we have,
Leave a comment