Generating random vectors in PyTorch

I am trying to generate several random vectors (of dimensionality d) such that

  1. All elements are drawn from a standard normal distribution (mean=0, std=1)
  2. The vector norms are 1
  3. The expectation of Sum of elements in each vector is 0 (expectation taken over the number of vectors generated)
  4. The sum of the generated vector yields a 0 vector, i.e. sum of elements in each dimension is 0.

I tried using the torch.randn() function to generate the whole tensor (of size N x d, where N is number of vectors) and use it to test if this set of vectors satisfies the above 4 conditions. As it turns out, condition 2 is satisfied pretty well but conditions 3 and 4 are not matched (it gets slightly better when N and d are increased but the error is often higher than I would want, e.g. setting N=d=1000 gives an error of order 1e-2 in both conditions).
Is there a better way to sample random vectors to match these conditions in pytorch? Also, is there a difference in using torch.randn() and torch.normal()?
Thanks in advance. :slight_smile: