SlowGuess/NeurIPS_2023_OCR huggingface dataset:
$$
\begin{array}{l} \nabla_ {\mathbf {x}} \log p _ {\mathrm {V}} (\mathbf {x}) = \underbrace {\nabla_ {\mathbf {x}} \log \frac {p _ {m}}{\mu \left(C _ {m}\right)}} _ {= 0} + \nabla_ {\mathbf {x}} \log \frac {\mathrm {d} \mu}{\mathrm {d} \lambda} (21a) \\ = \nabla_ {\mathbf {x}} \log \exp \left(- \frac {1}{2} | | \mathbf {g} _ {m} - \mathbf {x} | | _ {2} ^ {2}\right) - \underbrace {\nabla_ {\mathbf {x}} \log \mu (C _ {m})} _ {= 0} \\ = - \frac {1}{2} \nabla_ {\mathbf {x}} | | \mathbf {g} _ {m} - \mathbf {x} | | _ {2} ^ {2} (21b) \\ = \mathbf {g} _ {m} - \mathbf {x} (21c) \\ \end{array}
$$
Next, suppose  $\mathbf{x} \notin \bigcup_{m=1}^{M} C_m$ . Then, the measure is zero, so the gradient is as well. Finally, we have that  $\mathbf{x} \in \partial C_m$  for some  $m$ . Then, by the next Observation (Observation 1), we have that  $p_{\mathrm{V}}$  is discontinuous, so the derivative is not defined.
Observation 1. A  $(\mathcal{K},\mu)$ -Voronoi measure  $p_{\mathbb{V}}$  is differentiable with respect to  $p_m$  on the set  $\cup_{m=1}^{M}\mathrm{int}(C_m)$ , and discontinuous on the set  $\mathcal{K} \setminus \cup_{m=1}^{M}\mathrm{int}(C_m)$ , i.e., the union of the Voronoi cells' boundaries  $\cup_{m=1}^{M}\partial C_m$ .
14We use  $\mathcal{B}(\cdot)$  to denote the standard Borel  $\sigma$  -algebra.
D Properties of Hamiltonian Dynamics
Preservation of Measure. First of all, the Hamiltonian equations are volume- or measure-preserving. Intuitively, this means that if we move a region in the phase space along the dynamics for an arbitrary amount of time, the volume of the region would stay unchanged.[15] Concretely, we can define a function
$$
g ^ {t}: (\mathbf {x} (0), \mathbf {r} (0)) \mapsto (\mathbf {x} (t), \mathbf {r} (t)) \tag {22}
$$
as moving every point in the phase space along the Hamiltonian equations for some time  $t$ .<sup>16</sup> Then, using  $g^{t}$  as a change of variable would leave the underlying probability measure unchanged.
Time Reversibility. Next, the Hamiltonian equations are time reversible, meaning that if the equations can move  $(\mathbf{x},\mathbf{r})$  to  $(\mathbf{x}^{\prime},\mathbf{r}^{\prime})$ , then it would also take  $(\mathbf{x}^{\prime}, - \mathbf{r}^{\prime})$  to  $(\mathbf{x}, - \mathbf{r})$ . Due to our choice of distribution of  $\mathbf{r}$  is always symmetric, these properties simplify the acceptance probability to be only the energy difference, i.e., we can ignore the conditional probabilities in the standard Metropolis-Hastings acceptance probability.
Conservation of Hamiltonian. Finally, we can quickly verify that the Hamiltonian  $H$  is conserved by the Hamiltonian dynamics:
$$
\begin{array}{l} \frac {\mathrm {d} H}{\mathrm {d} t} = \sum_ {i} \frac {\partial H}{\partial \mathbf {x} _ {i}} \frac {\mathrm {d} \mathbf {x} _ {i}}{\mathrm {d} t} + \sum_ {i} \frac {\partial H}{\partial \mathbf {r} _ {i}} \frac {\mathrm {d} \mathbf {r} _ {i}}{\mathrm {d} t} (23) \\ = \sum_ {i} \frac {\partial H}{\partial \mathbf {x} _ {i}} \frac {\partial H}{\partial \mathbf {r} _ {i}} - \sum_ {i} \frac {\partial H}{\partial \mathbf {r} _ {i}} \frac {\partial H}{\partial \mathbf {x} _ {i}} \quad (\text {d e f i n i t i o n i n E q . (1 6)}) (24) \\ = \sum_ {i} \frac {\partial H}{\partial \mathbf {x} _ {i}} \frac {\partial H}{\partial \mathbf {r} _ {i}} - \sum_ {i} \frac {\partial H}{\partial \mathbf {x} _ {i}} \frac {\partial H}{\partial \mathbf {r} _ {i}} \quad (\text {s y m m e t r y}) (25) \\ = 0 (26) \\ \end{array}
$$
This shows that the acceptance probability will be exactly 1 if the Hamiltonian equations are integrated exactly. In practice, numerical errors will lead to fluctuations in  $H$ . The Metropolis-Hastings acceptance probability ensures detailed balance.
E Details of Voronoi Sampling
E.1 Conservation of Hamiltonian in Refraction-Reflection
Proposition 5. A single step of refraction-reflection conserves the Hamiltonian.
Proof. Suppose an instantaneous refraction-reflection takes  $(\mathbf{x},\mathbf{r})$  to  $(\mathbf{x}^{\prime},\mathbf{r}^{\prime})$ . In other words,  $(\mathbf{x},\mathbf{r})$  is the particle's coordinate and momentum at the boundary prior to the refraction-reflection, and  $(\mathbf{x}^{\prime},\mathbf{r}^{\prime})$  is the particle's coordinate and momentum after the refraction-reflection, which includes instantaneous changes in its potential energy and momentum. Recall the refraction-reflection equation is
$$
\mathbf {r} _ {\perp} ^ {\prime} = \left\{ \begin{array}{l l} \sqrt {\| \mathbf {r} _ {\perp} \| _ {2} ^ {2} - 2 \Delta U} \cdot \frac {\mathbf {r} _ {\perp}}{\| \mathbf {r} _ {\perp} \| _ {2} ^ {2}} & (\text {r e f r a c t i o n w h e n} \| \mathbf {r} _ {\perp} \| _ {2} ^ {2} > 2 \Delta U) \\ - \mathbf {r} _ {\perp} & (\text {r e f l e c t i o n w h e n} \| \mathbf {r} _ {\perp} \| _ {2} ^ {2} \leq 2 \Delta U) \end{array} \right. \tag {27a}
$$
This result is known as Liouville's theorem in classical mechanics [2, §16]. Upon noticing that the Hamiltonian dynamics is divergenceless, one can interpret it as a simple application of the (higher-dimensional) divergence theorem, which itself is a consequence of the generalized Stokes' theorem.
<sup>17</sup>We say a transformation taking  $(\mathbf{x},\mathbf{r})$  to  $(\mathbf{x}^{\prime},\mathbf{r}^{\prime})$  conserves Hamiltonian if  $H(\mathbf{x},\mathbf{r}) = H(\mathbf{x}^{\prime},\mathbf{r}^{\prime})$ .
This function is called the Hamiltonian phase flow, or simply Hamiltonian flow [2, §16]. Flow is a general and important notion in the study of differential equations and related subjects, in which some additive group acts on  $(\mathbb{R}, +)$ . In the case of a smooth Hamiltonian  $H$ ,  $\{g^t\}_{t \in \mathbb{R}}$  can be seen as a one-parameter group of diffeomorphisms over  $\mathbb{R}^{2d}$ .
where  $\mathbf{r} = \mathbf{r}_{\perp} + \mathbf{r}_{\parallel}$  is the normal decomposition of  $\mathbf{r}$  and  $\mathbf{r}' = \mathbf{r}_{\perp}' + \mathbf{r}_{\parallel}'$ . Then,
$$
\begin{array}{l} H \left(\mathbf {x} ^ {\prime}, \mathbf {r} ^ {\prime}\right) = U \left(\mathbf {x} ^ {\prime}\right) + \frac {1}{2} \| \mathbf {r} ^ {\prime} \| _ {2} ^ {2} (27b) \\ = U \left(\mathbf {x} ^ {\prime}\right) + \frac {1}{2} \left\| \mathbf {r} _ {\perp} ^ {\prime} + \mathbf {r} _ {\parallel} ^ {\prime} \right\| _ {2} ^ {2} (27c) \\ = U \left(\mathbf {x} ^ {\prime}\right) + \frac {1}{2} \left\| \mathbf {r} _ {\perp} ^ {\prime} \right\| _ {2} ^ {2} + \left\langle \mathbf {r} _ {\perp}, \mathbf {r} _ {\parallel} \right\rangle + \frac {1}{2} \left\| \mathbf {r} _ {\parallel} ^ {\prime} \right\| _ {2} ^ {2} (27d) \\ = U \left(\mathbf {x} ^ {\prime}\right) + \frac {1}{2} \left\| \mathbf {r} _ {\perp} ^ {\prime} \right\| _ {2} ^ {2} + \frac {1}{2} \left\| \mathbf {r} _ {\parallel} ^ {\prime} \right\| _ {2} ^ {2} \quad (\langle \mathrm {r} _ {\perp}, \mathrm {r} _ {\parallel} \rangle = 0) (27e) \\ = \left\{ \begin{array}{l l} U (\mathbf {x}) + \Delta U + \frac {1}{2} \left(\| \mathbf {r} _ {\perp} \| _ {2} ^ {2} - 2 \Delta U\right) + \frac {1}{2} \| \mathbf {r} _ {\parallel} ^ {\prime} \| _ {2} ^ {2} & \text {(r e f r a c t i o n)} \\ U (\mathbf {x}) + \frac {1}{2} \| - \mathbf {r} _ {\perp} \| _ {2} ^ {2} + \frac {1}{2} \| \mathbf {r} _ {\parallel} \| _ {2} ^ {2} & \text {(r e f l e c t i o n)} \end{array} \right. (27f) \\ = \left\{ \begin{array}{l l} U (\mathbf {x}) + \Delta \mathcal {U} + \frac {1}{2} \| \mathbf {r} _ {\perp} \| _ {2} ^ {2} - \Delta \mathcal {U} + \frac {1}{2} \| \mathbf {r} _ {\parallel} ^ {\prime} \| _ {2} ^ {2} & \text {(r e f r a c t i o n)} \\ U (\mathbf {x}) + \frac {1}{2} \| - \mathbf {r} _ {\perp} \| _ {2} ^ {2} + \frac {1}{2} \| \mathbf {r} _ {\parallel} \| _ {2} ^ {2} & \text {(r e f l e c t i o n)} \end{array} \right. (27g) \\ = U (\mathbf {x}) + \frac {1}{2} \| \mathbf {r} \| _ {2} ^ {2} (27h) \\ = H (\mathbf {x}, \mathbf {r}). (27i) \\ \end{array}
$$
E.2 Proof of Correctness
In this section, we give a proof of correctness of our sampler by establishing its detailed balance. We will first prove several useful properties of the sampler in E.2.1 to E.2.3 and then combine them to prove the detailed balance in App. E.2.4.
E.2.1 Measure Preservation in Leapfrog
First of all, we note that the two leapfrog steps are measure-preserving, since they are composed of a series of shear transformations.
Proposition 6. The leapfrog steps are measure-preserving.
Proof. Recall that the two leapfrog steps used in HMC (algorithm 1) are  $(\mathbf{x},\mathbf{r})\to (\mathbf{r},\mathbf{r} - \frac{\varepsilon}{2}\nabla U(\mathbf{x}))$  and  $(\mathbf{x},\mathbf{r})\rightarrow (\mathbf{x} + \varepsilon \mathbf{r},\mathbf{r})$ .
By the change-of-variable formula, to show a transformation is measure-preserving, it suffices to show that its Jacobian has determinant 1. The leapfrog step  $(\mathbf{x},\mathbf{r})\to (\mathbf{x},\mathbf{r} - \frac{\varepsilon}{2}\nabla U(\mathbf{x}))$  as a function has the Jacobian
$$
\frac {\partial (\mathbf {x} , \mathbf {r} - \frac {\varepsilon}{2} \nabla U (\mathbf {x}))}{\partial (\mathbf {x} , \mathbf {r})} = \left( \begin{array}{c c} I & 0 \\ - \frac {\varepsilon}{2} \nabla^ {2} U (\mathbf {x}) & I \end{array} \right) \tag {28}
$$
where  $\nabla^2 U(\mathbf{x})$  denotes the Hessian of  $U$ . This Jacobian (28) has determinant 1 and hence the leapfrog transformation  $(\mathbf{x},\mathbf{r})$  to  $(\mathbf{x},\mathbf{r} - \frac{\varepsilon}{2}\nabla U(\mathbf{x}))$  is measure preserving. Similarly, the other leapfrog step  $(\mathbf{x},\mathbf{r}) \to (\mathbf{x} + \varepsilon \mathbf{r},\mathbf{r})$  has Jacobian
$$
\frac {\partial (\mathbf {x} + \varepsilon \mathbf {r} , \mathbf {r})}{\partial (\mathbf {x} , \mathbf {r})} = \left( \begin{array}{c c} I & \varepsilon I \\ 0 & I \end{array} \right) \tag {29}
$$
which also has determinant 1.
E.2.2 Measure Preservation in Refraction-Reflection
The computation for showing that refraction and reflection steps are measure preserving is slightly more involved than the leapfrog case. Our proof below largely follows the one found in Mohasel Afshar and Domke [30], where we simplified and corrected some details.
Proposition 7. The refraction-reflection step is measure-preserving.
Proof. We consider a single step of refraction-reflection as a function  $\gamma$  that takes  $(\mathbf{x},\mathbf{r})$  to  $(\mathbf{x}^{\prime},\mathbf{r}^{\prime})$  with total step size  $\varepsilon$  and with only one discontinuity. Note that, without loss of generality, we may only consider the discontinuity surface to be the hyperplane  $\mathbf{x}_1 = 0$  since it is equivalent to any tangent hyperplane of the discontinuity (hyper)surface through an affine transformation. Then, a normal vector to the hyperplane  $\mathbf{x}_1 = 0$  is  $\mathbf{e}_1 = (1,0,\dots,0)$  and
$$
\mathbf {r} _ {\perp} = \left(\mathbf {r} _ {1}, 0, \dots , 0\right) \quad \text {a n d} \quad \mathbf {r} _ {\parallel} = \left(0, \mathbf {r} _ {2}, \dots , \mathbf {r} _ {d}\right). \tag {30}
$$
$$
\forall i \geq 2, \quad \mathbf {r} _ {i} ^ {\prime} = \mathbf {r} _ {i} \quad \text {a n d} \quad \mathbf {x} _ {i} ^ {\prime} = \mathbf {x} _ {i} + \varepsilon \mathbf {r} _ {i} \tag {31}
$$
since  $\mathbf{r}_{\parallel}$  is not affected by refraction-reflection. Therefore,
$$
\forall i \geq 2, \quad \frac {\partial \mathbf {x} _ {i} ^ {\prime}}{\partial \mathbf {x} _ {i}} = \frac {\partial \mathbf {r} _ {i} ^ {\prime}}{\partial \mathbf {r} _ {i}} = 1 \tag {32}
$$
$$
\forall i, j \geq 2 \text {a n d} j \neq i, \quad \frac {\partial \mathbf {x} _ {i} ^ {\prime}}{\partial \mathbf {x} _ {j}} = \frac {\partial \mathbf {x} _ {i} ^ {\prime}}{\partial \mathbf {r} _ {j}} = \frac {\partial \mathbf {r} _ {i} ^ {\prime}}{\partial \mathbf {x} _ {j}} = \frac {\partial \mathbf {r} _ {i} ^ {\prime}}{\partial \mathbf {r} _ {j}} = 0. \quad (\text {b y E q . (3 1)}) \tag {33}
$$
Eq. (32) and Eq. (33) shows that the absolute determinant of the Jacobian of  $\gamma$  is the same as
$$
| \det  \nabla \gamma | = \left| \det  \left( \begin{array}{c c} \frac {\partial \mathbf {x} _ {1} ^ {\prime}}{\partial \mathbf {x} _ {1}} & \frac {\partial \mathbf {x} _ {1} ^ {\prime}}{\partial \mathbf {r} _ {1}} \\ \frac {\partial \mathbf {r} _ {1} ^ {\prime}}{\partial \mathbf {x} _ {1}} & \frac {\partial \mathbf {r} _ {1} ^ {\prime}}{\partial \mathbf {r} _ {1}} \end{array} \right) \right| = \left| \frac {\partial \mathbf {x} _ {1} ^ {\prime}}{\partial \mathbf {x} _ {1}} \frac {\partial \mathbf {r} _ {1} ^ {\prime}}{\partial \mathbf {r} _ {1}} - \frac {\partial \mathbf {x} _ {1} ^ {\prime}}{\partial \mathbf {r} _ {1}} \frac {\partial \mathbf {r} _ {1} ^ {\prime}}{\partial \mathbf {x} _ {1}} \right|. \tag {34}
$$
We analyze all four quantities in Eq. (34) individually below. Again, without loss of generality, suppose  $\mathbf{x}_1 \leq 0$  and  $\mathbf{x}_1' \geq 0$ . Let  $\Delta U(\mathbf{x})$  be the function of the signed potential difference as  $\mathbf{x}_1$  changes from negative to positive, defined only when  $\mathbf{x}_1 = 0$ . Let  $\mathbf{y} = (0, \mathbf{y}_2, \ldots, \mathbf{y}_d)$  be the point where the discontinuity is encountered. In other words, the particle begins at  $\mathbf{x}$ , moved past  $\mathbf{y}$  and arrived at  $\mathbf{x}'$ .
Refraction. In the case of refraction,  $\mathbf{r}_1^2 > 2\Delta U(\mathbf{y})$  and
$$
\mathbf {r} _ {1} ^ {\prime} = \sqrt {\mathbf {r} _ {1} ^ {2} - 2 \Delta U (\mathbf {y})}. \tag {35}
$$
Let  $\delta$  be the step size it takes to reach  $\mathbf{y}$ . Then
$$
\delta = - \frac {\mathbf {x} _ {1}}{\mathbf {r} _ {1}}, \tag {36}
$$
$$
\mathbf {x} _ {1} ^ {\prime} = (\varepsilon - \delta) \mathbf {r} _ {1} ^ {\prime} = \left(\varepsilon + \frac {\mathbf {x} _ {1}}{\mathbf {r} _ {1}}\right) \mathbf {r} _ {1} ^ {\prime}, \tag {37}
$$
$$
\mathbf {y} = \mathbf {x} + \delta \mathbf {r} = \mathbf {x} - \frac {\mathbf {x} _ {1}}{\mathbf {r} _ {1}} \mathbf {r}. \tag {38}
$$
$$
\begin{array}{l} \frac {\partial \mathbf {x} _ {1} ^ {\prime}}{\partial \mathbf {x} _ {1}} = \frac {\partial}{\partial \mathbf {x} _ {1}} \left(\varepsilon + \frac {\mathbf {x} _ {1}}{\mathbf {r} _ {1}}\right) \mathbf {r} _ {1} ^ {\prime} (39a) \\ = \varepsilon \frac {\partial \mathbf {r} _ {1} ^ {\prime}}{\partial \mathbf {x} _ {1}} + \frac {1}{\mathbf {r} _ {1}} \mathbf {r} _ {1} ^ {\prime} + \frac {\mathbf {x} _ {1}}{\mathbf {r} _ {1}} \frac {\partial \mathbf {r} _ {1} ^ {\prime}}{\partial \mathbf {x} _ {1}} \quad (\text {p r o d u c t r u l e}) (39b) \\ = \left(\varepsilon + \frac {\mathbf {x} _ {1}}{\mathbf {r} _ {1}}\right) \frac {\partial \mathbf {r} _ {1} ^ {\prime}}{\partial \mathbf {x} _ {1}} + \frac {\mathbf {r} _ {1} ^ {\prime}}{\mathbf {r} _ {1}} \quad (\text {p r o d u c t r u l e}), (39c) \\ \end{array}
$$
$$
\begin{array}{l} \frac {\partial \mathbf {x} _ {1} ^ {\prime}}{\partial \mathbf {r} _ {1}} = \frac {\partial}{\partial \mathbf {r} _ {1}} \left(\varepsilon + \frac {\mathbf {x} _ {1}}{\mathbf {r} _ {1}}\right) \mathbf {r} _ {1} ^ {\prime} (40a) \\ = - \frac {\mathbf {x} _ {1} \mathbf {r} _ {1} ^ {\prime}}{\mathbf {r} _ {1} ^ {2}} + \left(\varepsilon + \frac {\mathbf {x} _ {1}}{\mathbf {r} _ {1}}\right) \frac {\partial \mathbf {r} _ {1} ^ {\prime}}{\partial \mathbf {r} _ {1}}, (40b) \\ \end{array}
$$
$$
\begin{array}{l} \frac {\partial \mathbf {r} _ {1} ^ {\prime}}{\partial \mathbf {x} _ {1}} = \frac {\partial \sqrt {\mathbf {r} _ {1} ^ {2} - 2 \Delta U (\mathbf {y})}}{\partial \mathbf {x} _ {1}} (41a) \\ = \frac {1}{2 \sqrt {\mathbf {r} _ {1} ^ {2} - 2 \Delta U (\mathbf {y})}} \frac {\partial \left(\mathbf {r} _ {1} ^ {2} - 2 \Delta U (\mathbf {y})\right)}{\partial \mathbf {x} _ {1}} \quad \text {(c h a i n r u l e)} (41b) \\ = - \frac {1}{\mathbf {r} _ {1} ^ {\prime}} \frac {\partial \Delta U (\mathbf {y})}{\partial \mathbf {x} _ {1}}, (41c) \\ \end{array}
$$
$$
\begin{array}{l} \frac {\partial \mathbf {r} _ {1} ^ {\prime}}{\partial \mathbf {r} _ {1}} = \frac {\partial \sqrt {\mathbf {r} _ {1} ^ {2} - 2 \Delta U (\mathbf {y})}}{\partial \mathbf {r} _ {1}} \quad \text {(b y E q . (3 5))} (42a) \\ = \frac {1}{2 \sqrt {\mathbf {r} _ {1} ^ {2} - 2 \Delta U (\mathbf {y})}} \frac {\partial \left(\mathbf {r} _ {1} ^ {2} - 2 \Delta U (\mathbf {y})\right)}{\partial \mathbf {r} _ {1}} \quad (42b) \\ = \frac {\mathbf {r} _ {1}}{\mathbf {r} _ {1} ^ {\prime}} - \frac {1}{\mathbf {r} _ {1} ^ {\prime}} \frac {\partial \Delta U (\mathbf {y})}{\partial \mathbf {r} _ {1}}. (42c) \\ \end{array}
$$
$$
\begin{array}{l} \det \nabla \gamma = \frac {\partial \mathbf {x} _ {1} ^ {\prime}}{\partial \mathbf {x} _ {1}} \frac {\partial \mathbf {r} _ {1} ^ {\prime}}{\partial \mathbf {r} _ {1}} - \frac {\partial \mathbf {x} _ {1} ^ {\prime}}{\partial \mathbf {r} _ {1}} \frac {\partial \mathbf {r} _ {1} ^ {\prime}}{\partial \mathbf {x} _ {1}} (Eq. (34)) \\ = \left(\left(\varepsilon + \frac {\mathbf {x} _ {1}}{\mathbf {r} _ {1}}\right) \frac {\partial \mathbf {r} _ {1} ^ {\prime}}{\partial \mathbf {x} _ {1}} + \frac {\mathbf {r} _ {1} ^ {\prime}}{\mathbf {r} _ {1}}\right) \frac {\partial \mathbf {r} _ {1} ^ {\prime}}{\partial \mathbf {r} _ {1}} - \left(\frac {\mathbf {x} _ {1} \mathbf {r} _ {1} ^ {\prime}}{\mathbf {r} _ {1} ^ {2}} + \left(\varepsilon + \frac {\mathbf {x} _ {1}}{\mathbf {r} _ {1}}\right) \frac {\partial \mathbf {r} _ {1} ^ {\prime}}{\partial \mathbf {r} _ {1}}\right) \frac {\partial \mathbf {r} _ {1} ^ {\prime}}{\partial \mathbf {x} _ {1}} \quad (\text {E q . (3 9) a n d (4 0)}) (43b) \\ = \frac {\mathbf {r} _ {1} ^ {\prime}}{\mathbf {r} _ {1}} \left(\frac {\partial \mathbf {r} _ {1} ^ {\prime}}{\partial \mathbf {r} _ {1}} + \frac {\mathbf {x} _ {1}}{\mathbf {r} _ {1}} \frac {\partial \mathbf {r} _ {1} ^ {\prime}}{\partial \mathbf {x} _ {1}}\right) (43c) \\ = \frac {\mathbf {r} _ {1} ^ {\prime}}{\mathbf {r} _ {1}} \left(\frac {\mathbf {r} _ {1}}{\mathbf {r} _ {1} ^ {\prime}} - \frac {1}{\mathbf {r} _ {1} ^ {\prime}} \frac {\partial \Delta U (\mathbf {y})}{\partial \mathbf {r} _ {1}} - \frac {\mathbf {x} _ {1}}{\mathbf {r} _ {1}} \frac {1}{\mathbf {r} _ {1} ^ {\prime}} \frac {\partial \Delta U (\mathbf {y})}{\partial \mathbf {x} _ {1}}\right) (Eq.43d) \\ = 1 - \frac {1}{\mathbf {r} _ {1}} \left(\frac {\partial \Delta U (\mathbf {y})}{\partial \mathbf {r} _ {1}} + \frac {\mathbf {x} _ {1}}{\mathbf {r} _ {1}} \frac {\partial \Delta U (\mathbf {y})}{\partial \mathbf {x} _ {1}}\right) (43e) \\ \end{array}
$$
$$
\begin{array}{l} \frac {\partial \Delta U (\mathbf {y})}{\partial \mathbf {r} _ {1}} + \frac {\mathbf {x} _ {1}}{\mathbf {r} _ {1}} \frac {\partial \Delta U (\mathbf {y})}{\partial \mathbf {x} _ {1}} (44a) \\ = \sum_ {i} \frac {\partial \Delta U (\mathbf {y})}{\partial \mathbf {y} _ {i}} \frac {\partial \mathbf {y} _ {i}}{\partial \mathbf {r} _ {1}} + \frac {\mathbf {x} _ {1}}{\mathbf {r} _ {1}} \sum_ {i} \frac {\partial \Delta U (\mathbf {y})}{\partial \mathbf {y} _ {i}} \frac {\partial \mathbf {y} _ {i}}{\partial \mathbf {x} _ {1}} \quad (44b) \\ = \sum_ {i} \frac {\partial \Delta U (\mathbf {y})}{\partial \mathbf {y} _ {i}} \frac {\mathbf {x} _ {1} \mathbf {r} _ {i}}{\mathbf {r} _ {1} ^ {2}} - \frac {\mathbf {x} _ {1}}{\mathbf {r} _ {1}} \sum_ {i} \frac {\partial \Delta U (\mathbf {y})}{\partial \mathbf {y} _ {i}} \frac {\mathbf {r} _ {i}}{\mathbf {r} _ {1}} (44c) \\ = 0. (44d) \\ \end{array}
$$
Hence, Eq. (43) and Eq. (44) together imply that
$$
| \det \nabla \gamma | = 1. \tag {45}
$$
So  $\gamma$  is measure-preserving in the case of refraction.
Reflection. In the case of reflection,  $\mathbf{r}_1^2\leq 2\Delta U(\mathbf{y})$  and
$$
\mathbf {r} _ {1} ^ {\prime} = - \mathbf {r} _ {1}. \tag {46}
$$
As in the case of refraction, let  $\delta$  be the step size it takes to reach  $\mathbf{y}$ . Then
$$
\delta = - \frac {\mathbf {x} _ {1}}{\mathbf {r} _ {1}}, \tag {47}
$$
$$
\mathbf {x} _ {1} ^ {\prime} = (\varepsilon - \delta) \mathbf {r} _ {1} ^ {\prime} = \left(\varepsilon + \frac {\mathbf {x} _ {1}}{\mathbf {r} _ {1}}\right) (- \mathbf {r} _ {1} ^ {\prime}) = - \varepsilon \mathbf {r} _ {1} ^ {\prime} - \mathbf {x} _ {1}. \tag {48}
$$
We can then directly calculate
$$
\frac {\partial \mathbf {x} _ {1} ^ {\prime}}{\partial \mathbf {x} _ {1}} = - 1, \frac {\partial \mathbf {x} _ {1} ^ {\prime}}{\partial \mathbf {x} _ {1}} = - \varepsilon , \tag {49a}
$$
$$
\frac {\partial \mathbf {x} _ {1} ^ {\prime}}{\partial \mathbf {x} _ {1}} = 0, \quad \frac {\partial \mathbf {x} _ {1} ^ {\prime}}{\partial \mathbf {x} _ {1}} = - 1. \tag {49b}
$$
$$
| \det  \nabla \gamma | = | (- 1) (- 1) - 0 \cdot (- \varepsilon) | = 1. \tag {50}
$$
So  $\gamma$  is measure preserving in the case of reflection as well.
E.2.3 Time Reversibility
Proposition 8. The refraction-reflection step is time-reversible.
Proof. A refraction-reflection step is time-reversible means that, if a single step of refraction-reflection procedure takes  $(\mathbf{x},\mathbf{r})$  to  $(\mathbf{x}^{\prime},\mathbf{r}^{\prime})$ , then it would also take  $(\mathbf{x}^{\prime}, - \mathbf{r}^{\prime})$  to  $(\mathbf{x}, - \mathbf{r})$ . We can show this by considering each case:
- Reflection: When reflection happens,  $\| \mathbf{r}_{\perp} \|_2^2 \leq 2\Delta U$ , and hence  $\| -\mathbf{r}_{\perp}' \|_2^2 = \| -\mathbf{r}_{\perp} \|_2^2 = \| \mathbf{r}_{\perp} \|_2^2 \leq 2\Delta U$ , meaning that the reverse trajectory would be reflected as well;
- Refraction: If  $\Delta U > 0$ , then the reverse trajectory is crossing the boundary from the other side, seeing a sudden decrease in potential, and hence would be refracted and regain the magnitude of momentum lost in the forward step. If  $\Delta U < 0$ , then  $\| - \mathbf{r}_{\perp}^{\prime}\|_{2}^{2} > 2\Delta U$  and hence the reverse trajectory would also be refracted, ending in the original momentum with the sign reversed.
Proposition 8, combined with time reversibility of leapfrog step as in basic HMC, shows that Voronoi sampling is time reversible. Hence we only need to use the Hamiltonian difference in the Metropolis-Hastings acceptance probability.
E.2.4 Detailed Balance
Theorem 1. A step of Structured Voronoi Sampling (Algorithm 4) satisfies the detailed balance.
Proof Sketch. From measure preservation (App. E.2.1 and App. E.2.2), the change of variable as introduced by integrating Hamiltonian equations have Jacobian with absolute determinant 1 and hence can be omitted. From time reversibility (App. E.2.3), we only need to use the Hamiltonian difference in the Metropolis-Hastings acceptance probability. And, finally, by using a Metropolis-Hastings accepting step (lines 8 to 13) we ensure the detailed balance.
E.3 Related Work
Such an integrator scheme appears to be well-known in the computational physics community, dating back to as early as Jin and Wen [18], and quite possibly even earlier. Integration algorithms based on this idea continue to receive active research [44].
The first usage of such integrator with discrete stepin the context of MCMC appeared in Mohasel Afshar and Domke [30].<sup>18</sup> Mohasel Afshar and Domke [30] primarily based their motivation on the optical reflection-refraction analogy. We note that, in fact, Hamiltonian mechanics originated from Hamilton's formulation of geometrical optics (or Hamiltonian optics) [22, §VIII.7]. This connection, important to modern physics, should be interpreted with care in our context since momentum isn't a natural quantity in optical rays.
In an earlier work, Pakman and Paninski [36] used the same idea but solved the trajectory exactly for simpler systems instead of using discrete steps.
Later, Nishimura et al. [33] provided a derivation of this integrator from the first principles of the calculus of variations [1]. Importantly, it should be noted that, due to the potential function being discontinuous, Eq. (16) loses its well-posedness as a system of differential equations, hence the necessity of justification based on non-smooth analysis.
Algorithm 2 Langevin Dynamics
Input:  $\mathbf{x}^t$ : current sample,  $U$ : potential energy function,  $\varepsilon$ : step size
Output: next sample:  $\mathbf{x}^{t + 1}$
1:  $\mathbf{r} \sim \mathcal{N}(\mathbf{0}, \mathbb{I})$
2:  $\mathbf{r} \gets \mathbf{r} - \frac{\varepsilon}{2} \nabla U(\mathbf{x}^t)$
3:  $\mathbf{x}^{t + 1}\leftarrow \mathbf{x}^t +\varepsilon \mathbf{r}$
4: return  $\mathbf{x}^{t + 1}$
Algorithm 3 MUCoLA