I have a problem that requires a distribution on the positive orthant (all dimensions >= 0) of the unit hypercube. Therefore,

$$ {\bf x} \in [0,1],\hspace{0.5cm}x_i = 1 \hspace{0.2cm}\text{ for some }\hspace{0.2cm}i \in \{1,\ldots,d\rbrace. $$

For a $d$-dimensional hypercube, there are $d-1$ degrees of freedom, so I can't simply use, for instance, a $d$-dimensional beta. Are there any distributions defined on this space? Alternatively, are there any dimension reduction techniques that I can transform it into a $d$-1 dimensional space?

I've currently used polar coordinate transformation, and I'm looking at the simplex now.

  • $\begingroup$ There are many ways to approach this. There is a nice one-to-one continuous map from the portion of the sphere $S^{d-1}$ in the positive orthant and this surface: given positive $y_i$ such that $y_1^2 + \cdots + y_d^2=1,$ let $y$ be the largest of these values and set $x = (y_1/y,y_2/y,\ldots,y_d/y).$ Thus you can use literally any distribution on the sphere in your application (after conditioning it on the positive orthant). Such distributions correspond to distributions on $\mathbb{R}^{d-1}$ (use Stereographic projection, for instance). $\endgroup$
    – whuber
    Jan 11, 2021 at 20:42

1 Answer 1


Just place all d-1-hypercubes on one plane next to each other, then sample from the constructed hyper-rectangle. There's 2d hypercubes of d-1 dimensions.

Then put back d-1 hypercubes back where they were. So the points will be on the surface of d-hypercube

Here's Python dem for 3D:

import numpy as np

d = 3
n = 1000
r = np.random.random(size=(n,d-1))
k = np.random.randint(d,size=(n,1))
j = np.random.randint(2,size=(n,1))
x = np.zeros((n,d))
for i in np.arange(n):
  x[i, np.arange(d)[np.arange(d)!=k[i]]] = r[i,:]
  x[i, k[i]] = j[i]

from mpl_toolkits.mplot3d import Axes3D  # noqa: F401 unused import
import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.scatter(x[:,0], x[:,1], x[:,2])


enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.