Volumes of high-dimensional sphere sectors
The following problem came up recently while thinking about “semantic-geometry” approaches to solving Semantle, following a questionSee also Victoria’s follow-up post discussing the semantic-geometry approach we came up with!
by my former colleague Victoria Ritvo.
Problem: Let , where . What is the volume of the regionFiguring 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 only interesting regime is when . For , a generic choice of produces an empty spherical sector, and any choice of vectors that does produce a nonempty sector must have redundant constraints.
- For reasonably large , naive Monte Carlo integration will be very inefficient because almost points on will not lie in the desired region.
The Gram matrix trick
The first observation we can make is that the problem is projectively symmetric: there’s no real dependence on . So we could express the volume fraction of the desired region as a probability for any spherically-symmetric distribution . The natural choice of spherically-symmetric distribution is the multivariate Gaussian . From here, we arrive at a remarkable fact: if , then the random variates 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 , 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 , we find that, writing , Since the are independent Gaussians, is itself a Gaussian, and hence are jointly distributed as a multivariate Gaussian.
We can calculate the mean and covariance of the vector fairly easily. We have and In other words, letting be the Gram matrix of the , we have
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 -action on , the Gram matrix construction separates -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- 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 for arbitrary vectors ,We allow , to have entries .
and an arbitrary matrix of full rank: that is, integrals of the form
We can immediately convert this more-general case into the special case of mean-zero Gaussians and axis-aligned parallelepipeds (i.e., those with ) via the following two steps:
- A shift centers the Gaussian, and preserves both general and axis-aligned parallelepipeds.
-
A linear change of variables aligns the region of integration along the axes, and changes the covariance matrixRecall that the PDF of a multivariate Gaussian uses the precision matrix , not the covariance matrix.to
Genz’s approach
Genz takes as starting point a Gaussian integral over an axis-aligned parallelepiped, i.e. some expression of the form 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:- We’ll get to fully standardize the Gaussian integrand.
- Our new region of integration will come with a convenient variable ordering where the limits for depend only on .
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 , 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 so that the covariance matrix becomes the identity.
The integration constraints then reduce to (writing for the entries of ):
Note the index constraints on the sums above: because is lower-triangular, the integration limits for depend only on the earlier variables . Then, writing and for the left- and right-hand sides of the constraints, our integral becomes
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 , where is the standard normal CDF. Writing , , our integral becomes
Now the integrand is really simple–it’s literally 1–but the region of integration is complicated. One more reparametrization fixes that: writing allows us to integrate in the over the unit cubeIn fact, we can drop the coordinate since the integrand is independent of .
as
Carrying all the substitutions through (though leaving the as intermediate variables), we haveSetting if and if .
If we squint, each factor in the integrand is a conditional probability: explicitly, it’s the probability that a standard normal falls in given the values of , 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.
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 a our Cholesky decomposition. Genz suggests having the variables with the widest integration intervals innermostAmusingly, 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.