normalized_vectors

halotools.utils.normalized_vectors(vectors)[source] [edit on github]

Return a unit-vector for each n-dimensional vector in the input list of n-dimensional points.

Parameters:
x : ndarray

Numpy array of shape (npts, ndim) storing a collection of n-dimensional points

Returns:
normed_x : ndarray

Numpy array of shape (npts, ndim)

Examples

Let’s create a set of semi-random 3D unit vectors.

>>> npts = int(1e3)
>>> ndim = 3
>>> x = np.random.random((npts, ndim))
>>> normed_x = normalized_vectors(x)