# n维空间下两个随机向量的夹角分布

$$\boldsymbol{x}=(x_1,x_2,\dots,x_n)$$

$$\boldsymbol{y}=(1,0,\dots,0)$$

）：

\left\{\begin{aligned}
x_{1}&=\cos(\varphi_{1})\\
x_{2}&=\sin(\varphi_{1})\cos(\varphi_{2})\\
x_{3}&=\sin(\varphi_{1})\sin(\varphi_{2})\cos(\varphi_{3})\\
&\,\,\vdots \\
x_{n-1}&=\sin(\varphi_{1})\cdots \sin(\varphi_{n-2})\cos(\varphi_{n-1})\\
x_{n}&=\sin(\varphi_{1})\cdots \sin(\varphi_{n-2})\sin(\varphi_{n-1})
\end{aligned}\right.

\arccos \langle \boldsymbol{x},\boldsymbol{y}\rangle = \arccos \cos(\varphi_{1}) = \varphi_{1}

\begin{aligned}
P_n(\varphi_1\leq\theta) =& \frac{\int_0^{2\pi}\cdots\int_0^{\pi}\int_0^{\theta}\sin^{n-2}(\varphi_{1})\sin^{n-3}(\varphi_{2})\cdots \sin(\varphi_{n-2})\,d\varphi_{1}\,d\varphi_{2}\cdots d\varphi_{n-1}}{\int_0^{2\pi}\cdots\int_0^{\pi}\int_0^{\pi}\sin^{n-2}(\varphi_{1})\sin^{n-3}(\varphi_{2})\cdots \sin(\varphi_{n-2})\,d\varphi_{1}\,d\varphi_{2}\cdots d\varphi_{n-1}}\\
=&\frac{\text{(n-1)维单位超球的表面积}\times\int_0^{\theta}\sin^{n-2}\varphi_{1} d\varphi_1}{\text{n维单位超球的表面积}}\\
=&\frac{\Gamma(\frac{n}{2})}{\Gamma(\frac{n-1}{2})\sqrt{\pi}} \int_0^{\theta}\sin^{n-2}\varphi_1 d\varphi_1
\end{aligned}

p_n(\theta) = \frac{\Gamma(\frac{n}{2})}{\Gamma(\frac{n-1}{2})\sqrt{\pi}}\sin^{n-2} \theta
\label{eq:theta}

\begin{aligned}
p_n(\eta)=&\frac{\Gamma(\frac{n}{2})}{\Gamma(\frac{n-1}{2})\sqrt{\pi}}\sin^{n-2} (\arccos\eta)\left|\frac{d\theta}{d\eta}\right|\\
=&\frac{\Gamma(\frac{n}{2})}{\Gamma(\frac{n-1}{2})\sqrt{\pi}}(1-\eta^2)^{(n-3)/2}\\
\end{aligned}\label{eq:cos}

Var_n(\theta) = \frac{\Gamma(\frac{n}{2})}{\Gamma(\frac{n-1}{2})\sqrt{\pi}}\int_0^{\pi}\left(\theta-\frac{\pi}{2}\right)^2\sin^{n-2} \theta d\theta

$$\begin{array}{c|c} \hline n & \text{方差}\\ \hline 3 & 0.467401\\ 10 & 0.110661\\ 20 & 0.0525832\\ 50 & 0.0204053\\ 100 & 0.0101007\\ 200 & 0.00502508\\ 1000 & 0.001001\\ \hline \end{array}$$

$$\ln \sin^{n-2}\theta=\frac{2-n}{2}\left(x – \frac{\pi}{2}\right)^2 + \mathscr{O}\left(\left(x – \frac{\pi}{2}\right)^4\right)$$

$$\sin^{n-2}\theta\approx exp\left[-\frac{n-2}{2}\left(x – \frac{\pi}{2}\right)^2\right]$$

https://kexue.fm/archives/7076

《科学空间FAQ》