def random_unit(size=<NUM_LIT:3>):
while True:<EOL><INDENT>result = np.random.normal(<NUM_LIT:0>, <NUM_LIT:1>, size)<EOL>length = np.linalg.norm(result)<EOL>if length > <NUM_LIT>:<EOL><INDENT>return result/length<EOL><DEDENT><DEDENT>
Return a random unit vector of the given dimension

       Optional argument:
         size  --  the number of dimensions of the unit vector [default=3]