Last active
December 13, 2022 12:49
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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