>>857
θとφの定義は下図に準拠
http://physics.thick.jp/Physical_Mathematics/Section3/figures/fig27.png

rm(list=ls())

vertex <- function(r=1){
x=runif(1,-1,1) # x ~ 一様分布[-1,1]
phi=runif(1,-pi,pi) # φ ~ 一様分布[-π,π]
y=sqrt(1-x^2)*cos(phi) # √(1-x^2)*cos(φ)
z=sqrt(1-x^2)*sin(phi) # √(1-x^2)*sin(φ)
r*c(x,y,z)
}

# 直交座標を極座標に
c2p <- function(xyz){ # (x,y,z) -> (θ,φ) Cartesian 2 Polar
x=xyz[1];y=xyz[2];z=xyz[3]
r=sqrt(x^2+y^2+z^2) # =1になるx,y,zの組合せ
theta=acos(z/sqrt(x^2+y^2+z^2)) # = acos(z) [0,π]の値
phi=ifelse(y>0,acos(x/sqrt(x^2+y^2)), # y>0ならφ < π
2*pi-acos(x/sqrt(x^2+y^2)))# y<0ならφ > π
c(theta,phi)
}

n=1e5
vtx=replicate(n,vertex()) # n個の点を作る

vtx=replicate(n,vertex()) # n個の点を作る
v=t(vtx) # 転置してn行3列(x,y,z)に
head(v,3) ; tail(v,3)
vp=apply(v,1,c2p) # 各行毎にx,y,z -> θ,φに変換
tp=t(vp) # theta θ, phai φ 転置してn行2列(θ,φ)に

fn <- function(x){ # 0<=φ & φ<=sin(θ)を満たすかを返す
θ=x[1]
φ=x[2]
0<=φ & φ<=sin(θ)
}
tp1=tp[apply(tp,1,fn),] # fnがTRUEになるθ,φを抽出して
θ=tp1[,1]
φ=tp1[,2]

plot(θ,φ*sin(θ),bty='n',pch='.', xlab='θ(北極点からのラジアン)',ylab='φ(経度)*sin(θ)')
# グラフ化

https://i.imgur.com/dtO0oRW.png

正弦波が描出されただけのような?