bundles / scipy 1.17.1 / scipy / stats / _multivariate / uniform_direction_gen
class
scipy.stats._multivariate:uniform_direction_gen
Signature
class uniform_direction_gen ( seed = None ) Members
Summary
A vector-valued uniform direction.
Extended Summary
Return a random direction (unit vector). The dim keyword specifies the dimensionality of the space.
Parameters
dim: scalarDimension of directions.
seed: {None, int, `numpy.random.Generator`,numpy.random.RandomState}, optional
Used for drawing random variates. If
seedisNone, the~np.random.RandomStatesingleton is used. Ifseedis an int, a newRandomStateinstance is used, seeded with seed. Ifseedis already aRandomStateorGeneratorinstance, then that object is used. Default isNone.
Methods
rvs(dim=None, size=1, random_state=None)Draw random directions.
Notes
This distribution generates unit vectors uniformly distributed on the surface of a hypersphere. These can be interpreted as random directions. For example, if dim is 3, 3D vectors from the surface of will be sampled.
Examples
import numpy as np from scipy.stats import uniform_direction x = uniform_direction.rvs(3)✓
np.linalg.norm(x)
✗rng = np.random.default_rng() uniform_sphere_dist = uniform_direction(3) unit_vectors = uniform_sphere_dist.rvs(5, random_state=rng)✓
unit_vectors
✗Aliases
-
scipy.stats._multivariate.uniform_direction_gen