Contents

Volumes of high-dimensional sphere sectors

Posted on April 13, 2026 by Daniel Vitek.
Tagged: , .
The following problem came up recently while thinking about “semantic-geometry” approaches to solving Semantle, following a question
See also Victoria’s follow-up post discussing the semantic-geometry approach we came up with!
by my former colleague Victoria Ritvo.

Problem: Let v1,,vnRdv_1, \cdots, v_n \in \mathbb{R}^d, where ndn \le d. What is the volume of the region {xSd1x,vi0 for all 1in}?\left\{x \in S^{d-1} | \langle x, v_i \rangle \ge 0\text{ for all }1 \le i \le n\right\}?

Figuring out how to solve this problem was a very fun little rabbit hole that taught me several new tricks and reminded me of some I’d forgotten. Let’s dive in!

As a warm-up, we’ll note two easy facts:

The Gram matrix trick

The first observation we can make is that the problem is projectively symmetric: there’s no real dependence on x\|x\|. So we could express the volume fraction of the desired region as a probability Pr[x,vi0xD]\Pr\left[ \langle x, v_i \rangle \ge 0 | x \sim \mathcal{D}\right] for any spherically-symmetric distribution D\mathcal{D}. The natural choice of spherically-symmetric distribution is the multivariate Gaussian N(0,Id)N(\mathbf{0}, \mathbf{I}_d).

From here, we arrive at a remarkable fact: if xN(0,Id)x \sim N(\mathbf{0}, \mathbf{I}_d), then the random variates Zi=x,viZ_i = \langle x, v_i\rangle are themselves distributed as a multivariate Gaussian. The easiest way to argue this is to use the Cramér-Wold theorem that a (Borel) probability measure is characterized by its one-dimensional projections. All of the one-dimensional projections of a multivariate Gaussian are themselves univariate Gaussians, so if we have a distribution all of whose one-dimensional projections are univariate Gaussians it must be a multivariate Gaussian.
More carefully, in order to apply Cramér-Wold the projections should be univariate Gaussians simultaneously arising from the corresponding projections of some multivariate Gaussian: they can’t just be any old univariate Gaussians. But it turns out that any nice-enough probability measure on Rn\mathbb{R}^n, all of whose one-dimensional projections (along arbitrary lines, not just the axes) are univariate Gaussians, must itself be a multivariate Gaussian: there’s a nice characteristic-function argument here.
And indeed, if we consider some random variate C=iciZiC = \sum_i c_iZ_i, we find that, writing x=(Xk)x = (X_k), C=icix,vi=icik=1d(vi)kXk.C = \sum_i c_i \langle x, v_i \rangle = \sum_i c_i \sum_{k=1}^d (v_i)_k X_k. Since the XkX_k are independent Gaussians, CC is itself a Gaussian, and hence ZiZ_i are jointly distributed as a multivariate Gaussian.

We can calculate the mean and covariance of the vector Z=(Zi)Z = (Z_i) fairly easily. We have E[Zi]=j=1d(vi)jE[Xj]=0\mathbb{E}[Z_i] = \sum_{j=1}^d (v_i)_j \mathbb{E}[X_j] = 0 and E[ZiZj]=1k,ld(vi)k(vj)lE[XkXl]=k=1d(vi)k(vj)k=vi,vj.\mathbb{E}[Z_iZ_j] = \sum_{1 \le k, l \le d}(v_i)_k (v_j)_l \mathbb{E}[X_kX_l] = \sum_{k=1}^d (v_i)_k (v_j)_k = \langle v_i, v_j \rangle. In other words, letting G\mathbf{G} be the Gram matrix of the viv_i, we have Pr[x,vi0xN(0,Id)]=Pr[Zi0ZN(0,G)].\Pr\left[ \langle x, v_i \rangle \ge 0 | x \sim N(\mathbf{0}, \mathbf{I}_d)\right] = \Pr\left[ Z_i \ge 0 | Z \sim N(\mathbf{0}, \mathbf{G})\right].

All this algebra is neat, but the point here is really valuable: we’ve transformed this somewhat-bespoke high-dimensional geometry problem into a more-straightforward (and, thankfully, well-studied) question in probability: what’s the measure of an orthant under a mean-zero Gaussian distribution?

Why should we have expected the Gram matrix to appear?

This can seem pretty magical, so let’s stop and think about why we could have expected the Gram matrix to pop up. The key point is that the Gram matrix is a complete invariant of sets of vectors up to orthogonal transformations. In more invariant-theoretic language, if we consider the simultaneous O(d)O(d)-action on (Rd)n(\mathbb{R}^d)^n, the Gram matrix construction separates O(d)O(d)-orbits. The spherical volumes we’re interested in are clearly unchanged under orthogonal transformations, so it makes sense to consider whether the geometry of this problem is easily expressed in terms of the Gram matrix. It’s still a little bit surprising to me that the answer is so neat, but hopefully this makes it less mysterious why the Gram matrix pops up.

Gaussian orthants

At this point, we’re left with the problem of computing probabilities of Gaussian orthants. Note that this Gaussian-orthant framing is no more susceptible to naive Monte Carlo integration than our original framing: we still have exponential-in-nn decay of the volume fractions. So we have to do a little more work, but thankfully this is a well-studied problem following seminal work of Genz.
Genz, A. (1992), Numerical computation of multivariate normal probabilities. Journal of Computational and Graphical Statistics, 1(2):141–149.

Opening moves

Let’s start by generalizing the problem a little bit. Above we consider only mean-zero distributions with domain of integration the positive orthant. We’ll generalize to allow arbitrary means and integration domains arbitrary parallelepipeds, i.e. regions of the form lAxu\mathbf{l} \le \mathbf{Ax} \le \mathbf{u} for arbitrary vectors l\mathbf{l}, u\mathbf{u}
We allow l\mathbf{l}, u\mathbf{u} to have entries ±\pm \infty.
and an arbitrary matrix ARn×n\mathbf{A} \in \mathbb{R}^{n \times n} of full rank: that is, integrals of the form lAxuexp[12(xμ)TΣ1(xμ)]dx.\int_{\mathbf{l} \le \mathbf{Ax} \le \mathbf{u}} \exp\left[-\frac{1}{2}(\mathbf{x}-\boldsymbol{\mu})^T \boldsymbol{\Sigma}^{-1} (\mathbf{x}-\boldsymbol{\mu}) \right] d\mathbf{x}.

We can immediately convert this more-general case into the special case of mean-zero Gaussians and axis-aligned parallelepipeds (i.e., those with A=I\mathbf{A} = \mathbf{I}) via the following two steps:

Genz’s approach

Genz takes as starting point a Gaussian integral over an axis-aligned parallelepiped, i.e. some expression of the form P=axbexp[12(xμ)TΣ1(xμ)]dx.P = \int_{\mathbf{a} \le \mathbf{x} \le \mathbf{b}} \exp\left[-\frac{1}{2}(\mathbf{x}-\boldsymbol{\mu})^T \boldsymbol{\Sigma}^{-1} (\mathbf{x}-\boldsymbol{\mu}) \right] d\mathbf{x}. Having just worked to axis-align our region of integration, the first step in Genz’s approach will be to undo this alignment. Why on earth would we do this? There are two upshots:

The key idea, which is common in multivariate statistics, is simply to take the Cholesky decomposition Σ=LLT\boldsymbol{\Sigma} = \mathbf{L}\mathbf{L}^T of the covariance matrix
If we had started with a non-axis-aligned parallelepiped, I believe we could simply take the LQ decomposition of the appropriate matrix and get to the desired integrand and region in one step (since QQ, being orthogonal, preserves the standard Gaussian measure). But I find this two-step process a little easier to understand.
and perform the change of variables x=Ly\mathbf{x} = \mathbf{L}\mathbf{y} so that the covariance matrix becomes the identity.

The integration constraints ai(Ly)ibia_i \le (\mathbf{L}\mathbf{y})_i \le b_i then reduce to (writing LijL_{ij} for the entries of L\mathbf{L}):

aij=1i1LijyjLiiyibij=1i1LijyjLii.\frac{a_i - \sum_{j=1}^{i-1} L_{ij} y_j}{L_{ii}} \le y_i \le \frac{b_i - \sum_{j=1}^{i-1} L_{ij} y_j}{L_{ii}}.

Note the index constraints on the sums above: because L\mathbf{L} is lower-triangular, the integration limits for yiy_i depend only on the earlier variables y1,,yi1y_1, \ldots, y_{i-1}. Then, writing ai(y1,,yi1)a'_i(y_1, \cdots, y_{i-1}) and bi(y1,,yi1)b'_i(y_1, \cdots, y_{i-1}) for the left- and right-hand sides of the constraints, our integral becomes P=a1b112πexp(y12/2)a2(y1)b2(y1)12πexp(y22/2)an(y1,,yn1)bn(y1,,yn1)12πexp(yn2/2)  dy.P = \int_{a'_1}^{b'_1} \frac{1}{\sqrt{2\pi}}\exp(-y_1^2/2) \int_{a'_2(y_1)}^{b'_2(y_1)} \frac{1}{\sqrt{2\pi}}\exp(-y_2^2/2) \cdots \int_{a'_n(y_1, \cdots, y_{n-1})}^{b'_n(y_1, \cdots, y_{n-1})} \frac{1}{\sqrt{2\pi}}\exp(-y_n^2/2) \;d\mathbf{y}.

From here, the rest of Genz’s approach is simply some straightforward reparametrizations to make the integral more suitable for off-the-shelf integration methods. We begin by making the substitution yi=Φ1(zi)y_i = \Phi^{-1}(z_i), where Φ\Phi is the standard normal CDF. Writing di=Φ(ai)d_i = \Phi(a'_i), ei=Φ(bi)e_i = \Phi(b'_i), our integral becomes

P=d1e1d2(z1)e2(z1)dn(z1,,zn1)en(z1,,zn1)dzndz1.P = \int_{d_1}^{e_1} \int_{d_2(z_1)}^{e_2(z_1)} \cdots \int_{d_n(z_1,\ldots,z_{n-1})}^{e_n(z_1,\ldots,z_{n-1})} dz_n \cdots dz_1.

Now the integrand is really simple–it’s literally 1–but the region of integration is complicated. One more reparametrization fixes that: writing zi=di+wi(eidi)z_i = d_i + w_i(e_i-d_i) allows us to integrate in the wiw_i over the unit cube
In fact, we can drop the wnw_n coordinate since the integrand is independent of wnw_n.
as

[0,1]n(e1d1)(e2d2)(endn)  dw.\int_{[0,1]^n} (e_1 - d_1)(e_2 - d_2) \cdots (e_n - d_n) \; d\mathbf{w}.

Carrying all the substitutions through (though leaving the yiy_i as intermediate variables), we have
Setting di=0d_i = 0 if ai=a_i = -\infty and ei=1e_i = 1 if bi=b_i = \infty.

yi1=Φ1(di1+wi1(ei1di1)),y_{i-1} = \Phi^{-1}(d_{i-1} + w_{i-1}(e_{i-1} - d_{i-1})), di=Φ ⁣(aij=1i1LijyjLii),ei=Φ ⁣(bij=1i1LijyjLii).d_i = \Phi\!\left(\frac{a_i - \sum_{j=1}^{i-1} L_{ij} y_j}{L_{ii}}\right), e_i = \Phi\!\left(\frac{b_i - \sum_{j=1}^{i-1} L_{ij} y_j}{L_{ii}}\right).

If we squint, each eidie_i-d_i factor in the integrand is a conditional probability: explicitly, it’s the probability that a standard normal falls in [ai,bi][a'_i, b'_i] given the values of y1,,yi1y_1, \ldots, y_{i-1}, so that the full product is a telescoping product of conditional probabilities coming from the Cholesky decomposition and the integral computes the joint probability we wanted.

Wrapping up

At this point we can just turn to standard Monte Carlo techniques and get a pretty good estimator in moderate dimensions. I believe that the sequential nature of the integrand (i.e., as a product of conditional probabilities) lends itself well to more-complicated Monte Carlo algorithms that save us relatively-expensive evaluations of Gaussian CDFs and inverse CDFs, but I’m not familiar enough with this literature to say anything more specific.

There’s also a subsidiary question of what variable ordering we should choose; this is essentially the only input to our Cholesky decomposition. Genz suggests having the variables with the widest integration intervals [ai,bi][a_i, b_i] innermost
Amusingly, this gives exactly zero guidance in our positive-orthant situation.
, and notes that this can make a substantial speedup; I think this question is fleshed out a bit more in follow-up literature.

To actually compute these orthant probabilities, we can use the R package mvtnorm written by Genz himself. Analogous implementations exist in SciPy, MATLAB, and Julia, and possibly elsewhere.