# Multi-variate normal distribution distance from vector sub-space

Let $X \sim {\cal N}(\mu,C)$ be a random variable obeying multi-variate normal distribution in $\mathbb{R}^n$ and $U \subset \mathbb{R}^n$ be a vector space with $\dim(U)=n-1$. What is the probability of $X$ to be at distance $(L_2)$ $d$ from $U$? Assume that $d$ is small (I am actually interested in $\lim\limits_{d \rightarrow 0} \frac{P(d)}{d}$ where $P(d)$ is the above probability.)

• Hint: what is the solution when $n=1$?
– whuber
Commented Dec 27, 2013 at 17:42
• @whuber: the $dim(U)=0$ for $n=1$.
– Stat
Commented Dec 27, 2013 at 17:54
• @Stat That's correct. A zero-dimensional vector subspace would be the origin; a zero-dimensional affine subspace would be any single point in $\mathbb{R}^1$. In either case the distribution of the distances is easy to obtain and so is the desired limiting ratio mentioned in the question.
– whuber
Commented Dec 27, 2013 at 17:55

Let us generally assume $U$ is an affine subspace. Letting $\nu$ be a unit normal to $U$ and $\delta$ the distance from $U$ to the origin (in the $\nu$ direction),

$$U = \{x\in \mathbb{R}^n \ |\ \nu \cdot x = \delta\}.$$

The vector $\nu$ can be completed to a basis $\{\nu, e_2, e_3, \ldots, e_n\}$ of $\mathbb{R}^n$ in which $\nu$ is orthogonal to all the $e_i.$ In this basis the distribution becomes the product of a Normal distribution in the $\nu$ direction with variance $\nu\prime C \nu$ and mean $\nu\cdot \mu$ and the distance between any $x$ and $U$ is $|\nu \cdot x - \delta|$. The question is thereby reduced to this one-dimensional context where the answer is readily obtained.

### Example

Suppose $X$ is bivariate Normal with mean $(2,-3)$ and diagonal variance matrix $\Sigma$ having $4$ and $1$ on the diagonals. Let $U$ be the hyperplane given by normal vector $(1,1)$ and distance $1$ from the origin. Here are 10,000 simulated values along with $U$ (a line, shown in red). Simulated points within 0.05 of $U$ are highlighted.

Using a million ($10^6$) simulated values, the limiting ratio of $P(d)/d$ is estimated as $0.1411 \pm 0.00035$. The correct value, computed as described above, is $0.14087,$ in satisfactory agreement. The R code to produce this simulation, draw the plot, and compute the correct value follows.

#
# Simulate from a multivariate normal distribution.
#
require(mvtnorm)
set.seed(17)
sigma <- diag(c(4, 1))
mu <- c(2, -3)
N <- 10^6
x <- rmvnorm(N, mu, sigma)
if (N <= 10^4) plot(x, cex=1/2, col="#00000040", asp=1)
#
# Describe and plot an affine hyperplane nu.x == d.
#
nu <- c(1,1)/sqrt(2)
d <- 1
if (N <= 10^4) abline(1/nu[2], -nu[1]/nu[2], col="Red")
#
# Show values close to the hyperplane and estimate their probability.
#
eps <- 0.05
i <- abs(x %*% nu - d) < eps
if (N <= 10^4) points(x[i, ], cex=1/2, col="Red")
p <- mean(i) / (2*eps)
n.dec <- ceiling(log(N, base=10)/2)+1
#
# Perform an exact calculation.
#
s <- nu %*% sigma %*% nu
z <- dnorm(d, mean=sum(nu*mu), sd=sqrt(s))
#
# Display the results.
#
cat("Lim(P(d)/d) equals", round(z, n.dec+1))
cat("Lim(P(d)/d) is approximately", round(p, n.dec),
"+-", round(sqrt(p*(1-p)/N), n.dec+1))


This code only computes the limiting probability to be at distance $0$ from $U$. When performing the calculation for nonzero distances, do not forget that there are two sides to the hyperplane: you must double the value of the normal PDF.