Random planar angle by inverse-transform sampling
Source:R/cone_sampling.R
generate_planar_angle_inverse.RdDraws a single random planar angle \(\theta \in [0, \theta_0]\) from the distribution required to produce uniform sampling on a spherical cap of half-angle \(\theta_0\) in dimension \(n\), using the inverse cumulative distribution map \(\theta = \Theta^{-1}(U)\) with \(U \sim \mathrm{Uniform}(0, \Omega_0)\).
Details
The cumulative distribution function of \(\theta\) restricted to
\([0, \theta_0]\) is \(F_\theta(\theta) = \Theta(\theta) / \Theta(\theta_0)\),
where \(\Theta\) is implemented by theta_to_omega.
Inverse-transform sampling generates one random angle per call by
drawing \(U \sim \mathrm{Uniform}(0, \Omega_0)\) with
\(\Omega_0 = \Theta(\theta_0)\) and returning \(\Theta^{-1}(U)\)
through omega_to_theta.
This formulation requires both \(\Theta\) and \(\Theta^{-1}\), both
of which can underflow for very large \(n\) and very narrow caps; in
that regime generate_planar_angle_rejection is preferred.
References
Arun, I., & Venkatapathi, M. (2025). An O(n) algorithm for generating uniform random vectors in n-dimensional cones. Sankhya A, 87(2), 327-348. doi:10.1007/s13171-025-00387-9
See also
generate_planar_angle_rejection for the rejection-based
alternative that is numerically stable in high dimensions;
theta_to_omega, omega_to_theta for the
underlying maps; generate_cone_sample for the downstream
cone sampler that consumes this random angle.