1

I'm trying to write code to generate N points as far as possible from each other on a D dimensional hypersphere. The method I have so far is to take the number of points and hope it's less than D or 2*D, which it usually will be. Then I create N vectors that are 0 at every index except at index n where n is between 1 and N/2 and then duplicate that times it by -1 then append it, but I think that'll only generate points equally spaced apart on a portion of a sphere. Here's my code

import numpy as np

start = np.eye(D)[:N/2]
points = np.cat((start, -1*start), axis=1)
Spektre
  • 49,595
  • 11
  • 110
  • 380
  • 2
    Does this answer your question? [How to distribute points evenly on the surface of hyperspheres in higher dimensions?](https://stackoverflow.com/questions/57123194/how-to-distribute-points-evenly-on-the-surface-of-hyperspheres-in-higher-dimensi) – Spektre Apr 10 '21 at 07:48
  • see all the answers in here [How to distribute points evenly on the surface of hyperspheres in higher dimensions?](https://stackoverflow.com/a/57240140/2521214) and pick approach that is best for your task. If you need something exact then you need to do [Fibonacci lattice](https://observablehq.com/@mbostock/spherical-fibonacci-lattice) in ND which is not easy to implement or subdivide [ND simplex and align it to surface of hypersphere](https://stackoverflow.com/a/29139125/2521214) however booth of these will get specific number of points not arbitrary one !!! – Spektre Apr 10 '21 at 07:51
  • 1
    It's a difficult math problem with no simple solution. If you're happy with a probabilistic solution (points that are uniformly distributed on a hypersphere), then generating points from a multivariate normal distribution and normalizing them is the easiest way. See [this answer](https://math.stackexchange.com/a/1585996/255975) for example in 3D. – roygbiv Apr 10 '21 at 17:01
  • @roygbiv very intereseting +1 ... and very similar to my second answer in the first link I commented above (except I do not use PRNG and generate very similar distribution directly instead) ... also gauss distribution can be done by doing sum of multiple (4++) normal distributions so `x=Random()+Random()+....+Random();` – Spektre Apr 11 '21 at 07:37

1 Answers1

0

I found a cool method called predefined evenly-distributed class centroids:

https://github.com/anlongstory/CSAE/blob/master/PEDCC.py

An elaboration of the method is in this paper A Classification Supervised Auto-Encoder Based on Predefined Evenly-Distributed Class Centroids