numpy - Generating random vectors of Euclidean norm <= 1 in Python? -
more specifically, given natural number d, how can generate random vectors in r^d such each vector x has euclidean norm <= 1?
generating random vectors via numpy.random.rand(1,d) no problem, likelihood of such random vector having norm <= 1 predictably bad not-small d. example, d = 10 0.2% percent of such random vectors have appropriately small norm. seems silly solution.
edit: re: walter's comment, yes, i'm looking uniform distribution on vectors in unit ball in r^d.
based on wolfram mathworld article on hypersphere point picking , nate eldredge's answer similar question on math.stackexchange.com, can generate such vector generating vector of d
independent gaussian random variables , random number u
uniformly distributed on closed interval [0, 1]
, normalizing vector norm u^(1/d)
.