5
$\begingroup$

I can create a large collection of normalized real valued $n$-dimensional vectors from some random process which I hypothesis should be equidistributed on the unit sphere. I would like to test this hypothesis.

  • What is a good way numerically to test if vectors are equidistributed on the unit sphere? I am writing computer code so I will be testing that way
  • Is there some way to visualise the distribution given that my vectors are in $n$ dimensions?
$\endgroup$
5
  • $\begingroup$ It will probably help to read the answers to this question: math.stackexchange.com/questions/44689/… One of the techniques given can be generalized from three dimensions to $n$ (according to the answer). $\endgroup$
    – bubba
    Apr 2, 2016 at 11:08
  • 1
    $\begingroup$ @bubba Isn't that about generating vectors rather than testing is already generated ones are uniformly distributed on the unit sphere? $\endgroup$
    – user35671
    Apr 2, 2016 at 11:18
  • $\begingroup$ This is related to the sphere covering problem. You can check how they measure equidistribution in that context. $\endgroup$
    – littleO
    Apr 2, 2016 at 11:48
  • $\begingroup$ Yes, it's about generating random vectors, but I still thought it might be relevant $\endgroup$
    – bubba
    Apr 2, 2016 at 12:14
  • 1
    $\begingroup$ An overview of uniformity tests on the hypersphere: arxiv.org/pdf/1804.00286.pdf $\endgroup$
    – user51547
    Jan 6 at 0:19

3 Answers 3

2
$\begingroup$

In the whole vector space defined by your normalised vectors in $\mathbb{R}^n$, you can try to find the inner product of the vectors (in $\mathcal{L}_2$ space) and with the output, you can decide whether it is equidistributed on the unit sphere (n-dimension).

This is one of the numerically reliable method.

$\endgroup$
2
  • 2
    $\begingroup$ The set of unit vectors is a vector space?? I don't think so. $\endgroup$
    – bubba
    Apr 2, 2016 at 11:00
  • $\begingroup$ in the $\mathcal{L}_2$ space, where the (n-dimensional) normalised vector lies. $\endgroup$ Apr 2, 2016 at 12:28
2
$\begingroup$

From this paper by Cai, Fan, Jiang: you can calculate angles $\theta_{ij}$ between pairs of vectors $\vec{v}_i$, $\vec{v}_j$ from your collection, $1 \leq i < j \leq N$ (where $N$ is the total number of vectors). If the vectors have a uniform distribution on the $(n-1)$-sphere, then these angles should be distributed according to $$ h(\theta) = \frac{1}{\sqrt{\pi}} \frac{\Gamma\left(\frac{n}{2}\right)}{\Gamma\left(\frac{n-1}{2}\right)} \cdot \left(\sin \theta\right)^{n-2}, \quad \theta\in[0,\pi], $$ where $\Gamma(n)$ is the gamma function. This is a necessary condition for the uniform distribution on a sphere. And if I understand correctly, it is also sufficient (correct me if I am wrong - I am not an expert on this topic).

Here is a code in python that illustrates this.

import numpy as np
from numpy import sqrt, sin, arccos, pi
from numpy.linalg import norm
from scipy.special import gamma
import matplotlib.pyplot as plt

n = 15      # space dimension
N = 10000   # number of vectors

# Generate vectors (columns of v) uniformly distributed on the (n-1)-sphere
v = np.random.normal(0, 1, (n, N))
v_norms = norm(v, axis=0)
v = v / v_norms

# Calculate the angles between pairs of vectors
thetas = v.T @ v
thetas = thetas[np.triu_indices_from(thetas, 1)]
thetas = arccos(thetas)

# Plotting
fig, ax = plt.subplots(figsize=(14, 8), tight_layout=True)
ax.set_ylabel('pdf', fontsize=20)
ax.set_xlabel(r'$\theta_{ij}$', fontsize=20)
ax.hist(thetas, bins='auto', density=True, label='observed distribution')
x = np.linspace(0, pi, num=1000)
ax.plot(x, 1/sqrt(pi) * gamma(n/2)/gamma((n-1)/2) * (sin(x))**(n-2), color='red', linestyle='--', label=r'$\frac{1}{\sqrt{\pi}} \frac{\Gamma(n/2)}{\Gamma\left(\frac{n-1}{2}\right)} \left(\sin(\theta)\right)^{n-2}$')
plt.legend(loc='upper right', prop={'size': 18}, markerscale=4)
ax.set_xlim(0, pi)

plt.show()

picture

P.S. Book "Symmetric Multivariate and Related Distributions" by Fang, Kotz, Ng (1990) is another relevant reading on this topic.

$\endgroup$
1
  • $\begingroup$ Real nice, works great $\endgroup$ Mar 3 at 13:00
1
$\begingroup$

I would proceed on the basis that a (hollow) sphere with $N$ mass = $1$ points uniformly distributed shall have mass-centre (1st moment) =$0$, moment of inertia (2nd moment) = $\rho (n)N$, around any ax. Where $\rho (n) = 2/3$ in the case $n=3$, while for the n-dimensional sphere in general it shall be calculated .

Therefore the $n$-vector of the mass-centre and that of the inertia could be a start to statistically evaluate the hypothesis of uniform distribution.

$\endgroup$

You must log in to answer this question.