Skip to content

d1mav0lk0v/random_hypersphere_hyperball

Repository files navigation

Random points on sphere or in ball

Info

Implementation of two functions for obtaining random points on the surface of a sphere and inside a ball.

random_sphere

  1. Take a random number from the normal (Gaussian) distribution of numbers over the number of dimensions for each point.
  2. For each point, calculate the norm (Euclidean) and divide the coordinates by this norm.
  3. If necessary, transform the center and radius (semi-axes).

random_ball

  1. Perform steps 1 and 2 from the previous algorithm.
  2. 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
  3. If necessary, transform the center and radius (semi-axes).

Information taken from the link.


Prerequisites

Language version starting from Python 3.10+ and package Numpy

$ python --version
Python 3.10.4

Demo

2D Sphere 2D Ball 3D Sphere 3D Ball


Authors


Link


About

Random points on sphere or in ball

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages