Skip to contents

Get a random unit vector with num_dims components.

Usage

rand_unit_vector(num_dims)

Arguments

num_dims

Number of components in vector (i.e. vector size).

Value

A random unit vector with num_dims components.

Note

This function is stochastic. For reproducibility set a PRNG seed with set.seed.

Examples

r <- rand_unit_vector(4)
norm(r, "2")
#> [1] 1