0

I was wondering what is the best way to:

Generate t = 160 unit vectors in Rd for d = 100.

Plot of cdf of their pairwise dot products aka calculate 160C2 dot products.

Edit: So I'm stuck with plotting the CDF, how do you derive the CDF from the dot product? Im guessing it is some sort of Gaussian distribution

user3750556
  • 11
  • 1
  • 3
  • Did you find a way that is not the best? What is the last sentence supposed to mean, is it a question? – mkrieger1 Feb 02 '20 at 00:36
  • What was wrong with generating 100 random numbers, normalizing the length of the resulting vector to 1, and repeating this 160 times? – mkrieger1 Feb 02 '20 at 00:38
  • @mkrieger1 Plot of cdf of their pairwise dot products aka calculate 160C2 dot products. – user3750556 Feb 02 '20 at 03:16
  • I guess I am trying to generate a single random unit vector in d = 100 dimensions using only the operation u ← unif (0, 1) which generates a uniform random variable between 0 and 1, then loop through 160 times, then plot their product – user3750556 Feb 02 '20 at 03:20

1 Answers1

0
v = np.random.rand(100)
v_hat = v / linalg.norm(v)

This will get you a random unit vector. How to get the unit vector from a numpy array

Knl_Kolhe
  • 191
  • 8
  • 4
    The random numbers should be normally distributed, not uniformly distributed. See also [Sphere Point Picking](http://mathworld.wolfram.com/SpherePointPicking.html). – Peter O. Feb 02 '20 at 06:12
  • Agree with @Peter O, it has to be gaussian, not uniform to not have corner effect in high dimension, or else it has to go through Box-Muller transform – user3750556 Feb 02 '20 at 20:43
  • @PeterO. I am not aware of the context for this question. I just gave a code for generating a random unit vector. – Knl_Kolhe Feb 03 '20 at 07:30
  • Tiny thing: I'd add `np` in front of `linalg.norm`, to make the usage consistent with the usage of `random` above. I'd make this edit myself, but stackoverflow won't let me make an edits that small. – Damien Apr 19 '21 at 11:52