Generate points uniformly distributed on spherical surface
Generate points uniformly distributed on spherical surface
f_θ[θ_]=Sin[θ]/2(*probabilitydensityfunctionofθ*)
(Local) Out[]=
Sin[θ]
2
inv_F_θ[x_]=ArcCos[1-2x](*inversecumulativedistributionfunctionofθ*)
(Local) Out[]=
ArcCos[1-2x]
(Local) In[]:=
N_pts=10000;(*thenumberofthepointstobegenerated*)
samples_θ=Map[inv_F_θ,RandomReal[{0,1},N_pts]];(*samplesofθ*)
Histogram[samples_θ,30]
(Local) Out[]=
samples_φ=RandomReal[{0,2Pi},N_pts];(*samplesofφ*)
Histogram[samples_φ,30]
(Local) Out[]=
samples_point=Table[{Sin[samples_θ[[i]]]*Cos[samples_φ[[i]]],Sin[samples_θ[[i]]]*Sin[samples_φ[[i]]],Cos[samples_θ[[i]]]},{i,Length[samples_θ]}];(*samplesofpoint*)
Dimensions[samples_point]
(Local) Out[]=
{10000,3}
ListPointPlot3D[samples_point,AxesLabelMap[Style[#,16]&,{"x","y","z"}],AspectRatio1]
(Local) Out[]=