sphrand#
- torchspin.sphrand(N, k=4)[source]#
Generate N random orientations uniformly distributed on the sphere.
Port of EasySpin’s
sphrand.m.- Parameters:
- Returns:
phi (ndarray, shape (N,)) – Azimuthal angles in radians.
theta (ndarray, shape (N,)) – Polar angles in radians (from +z axis).
Notes
Orientations are drawn from a uniform distribution on the sphere restricted to the requested octant.
cos(theta)is drawn from a uniform distribution (not theta itself) to avoid polar crowding.Examples
>>> phi, theta = sphrand(1000) # 1000 orientations, upper octant >>> phi, theta = sphrand(500, k=2) # upper hemisphere >>> phi, theta = sphrand(200, k=1) # full sphere