Implementation of two functions for obtaining random points on the surface of a sphere and inside a ball.
random_sphere
- Take a random number from the normal (Gaussian) distribution of numbers over the number of dimensions for each point.
- For each point, calculate the norm (Euclidean) and divide the coordinates by this norm.
- If necessary, transform the center and radius (semi-axes).
random_ball
- Perform steps 1 and 2 from the previous algorithm.
- Take a random radius, the probability of which corresponds to the surface area of a ball with this radius in n dimensions. Multiply all points by their radii
- If necessary, transform the center and radius (semi-axes).
Information taken from the link.
Language version starting from Python 3.10+ and package Numpy
$ python --version
Python 3.10.4