Im working in an assigment that ask me to create a d-dimensional variable x that is uniformely distributed on the unit sphere such that its norm equals 1 (x_n c R^d, ||x_n||_2 = 1). I know how to create multivariate uniform variables, however I'm unable to recreate the added constrain.
Right now I have the following
import numpy as np
trainN = 200
testN = 50
d = 5
xTest = np.random.random((testN, d))
xTrain = np.random.random((testN, d))
for i in xTrain:
print(np.linalg.norm(i))
However, this doesnt seem like the proper aproach to me, as x is not restricted to [0,1], and the norms vary wildly between entrances.
Could someone lend me a hand?