Skip to content

Instantly share code, notes, and snippets.

@marmakoide
Last active December 13, 2022 12:49
Show Gist options
  • Save marmakoide/64c4f83f4a24b19de4cdf723d7e13294 to your computer and use it in GitHub Desktop.
Save marmakoide/64c4f83f4a24b19de4cdf723d7e13294 to your computer and use it in GitHub Desktop.
Computes the coordinates of the regular simplex inscribed in the unit sphere, in N-dimension
import numpy
def get_unit_simplex(N, dtype = float):
# Original algorithm from John Burkardt
A = numpy.full(N, (1. - numpy.sqrt(N + 1)) / N, dtype = dtype)
S = numpy.concatenate([A[:,None].T, numpy.identity(N, dtype = dtype)])
S -= numpy.mean(S, axis = 0)
S /= numpy.sqrt(2.)
return S
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment