random#

classmethod Rotation.random(shape: int | tuple = 1) Quaternion[source]#

Return uniformly distributed random data.

For objects that map to the surfaces of n-dimensional unit spheres (unit vectors, quaternions, octonions, etc), randomly sampling values for each axis gives a non-uniform sampling that coalesces near the poles. One proper method is to instead sample an n-dimensional gaussian distribution for each axis, then normalize the result.

For vectors, this would produce a uniform sampling of the 2D surface of the 3D unit sphere.

For rotations, this would be a uniform sampling of the 3D surface of the 4D quaternion unit sphere.

Note that this is not the only definition of a “random” sample, but is the one most commonly appropriate when discussing vectors and rotations in crystallography.

Parameters:
shape

Data shape.

Returns:
obj

Random data.

Examples using Rotation.random#

Color scatter plots

Color scatter plots

Visualizing orientations

Visualizing orientations

Visualizing paths between rotations and vectors

Visualizing paths between rotations and vectors