2

As stated in the question, I'm looking for a way to generate uniformly distributed points inside n-dimensional unit cube. For the surface of the sphere, I can find some obvious solution but cannot find for this case. Thanks for your help.

  • 1
    What do you mean by "uniformly distributed"? It sounds like you would just take each coordinate to be a uniformly distributed random variable on $[0,1]$ so pick $n$ of them and you're set. Or do you mean something else? – RobertTheTutor Apr 01 '21 at 12:25
  • @RobertTheTutor Hi Robert, what I mean for that is like I want to generate points with normal distribution. The output is a n-by-k matrix with n points, each point is k-dimensional – Eden Willy Apr 01 '21 at 12:27
  • Normal distributions go from $-\infty$ to $\infty$. You said you want values inside the unit $n$-cube. Do you mean to discard points that fall outside of it? And is the center of the distribution the center of the cube, or a corner? – RobertTheTutor Apr 01 '21 at 12:34
  • Oh sorry, my fault, it should be uniform distribution of points inside the cube, not normal distribution. – Eden Willy Apr 01 '21 at 12:39
  • Evenly distributing points on a sphere is notoriously difficult problem even for $S^2$. See https://math.stackexchange.com/a/9859/589 – lhf Apr 01 '21 at 13:20
  • @RobertTheTutor Hi Robert, I think your suggestion is correct. However, I have a question about this. When I try to generate coordinate, what should I do with the point outside of the range [0,1]? – Eden Willy Apr 01 '21 at 13:47
  • If you want a uniform distribution in an $n$-cube, just generate uniform random numbers on $[0,1]$, which is the base case for computer random number generators anyway. Each one can be a coordinate of your desired point. You won't have any numbers out of range to throw away that way, like you would if you used normal distribution. – RobertTheTutor Apr 01 '21 at 14:39
  • @RobertTheTutor oh I got it, thank you so much. What made me confused is that I did the case of points on an n-sphere, which I have to generate normal distribution, but in this case, just use uniform distribution. – Eden Willy Apr 01 '21 at 15:24

0 Answers0