Warm-up in 3D
Let's place a sphere of radius $r$ at the origin and a smaller sphere of radius $\epsilon$ at $(0, 0, r)$ (i.e., on the intersection of the z-axis with the surface of the larger sphere).
We're interested in their intersection, so any points that jointly satisfy $$ x^2 + y^2 + z^2 = r^2, $$ and $$ x^2 + y^2 + (z-r)^2 = \epsilon^2. $$
I.e.: $$ z = r - \frac{\epsilon^2}{2r}, $$ and $$ x^2 = \epsilon^2 - \frac{\epsilon^4}{4r^2} - y^2. $$
Which suggests a way to sample points uniformly from the intersection: uniformly sample $y \in [-(\epsilon^2-\epsilon^4/4r^2), \epsilon^2 - \epsilon^4/4r^2]$, then compute the corresponding $x$ (sign given by a coin flip).
Generalization
How do we generalize this to higher dimensions, $D$? In a way where the sampling is guaranteed to be uniform over the $D-1$-dimensional intersection? What about when the smaller sphere is placed at an arbitrary point on the surface?
Bonus
I'm interested in this from the context of initializing a weight matrix for a neural network. My aim is to explore what small perturbations to the initial matrix do to the results of training.
In this case, we know that the components of the original matrix are generated i.i.d. from a uniform or normal distribution. I've modified the weight initialization scheme to guarantee that the weight matrix has a fixed norm (equal to the limiting value of Kaiming-He initialization for large matrices). Is there any way to guarantee in general that:
- These perturbations stay on the same hypersurface at a fixed distance (the problem above), and
- the components of the perturbed matrix follow from the same initialization distribution.