Let \(p=(p_1,\dots,p_k)\) denote the empirical distribution of \(Y\).
The function returns two scalars:
OPDempDist: \(\mathbb{E}|\,\hat Y-Y\,|\) when
\(\hat Y\sim p\) independently of \(Y\sim p\).
OPDur: \(\mathbb{E}|\,\hat Y-Y\,|\) when
\(\hat Y\sim \mathrm{Unif}\{1,\dots,k\}\) independently of
\(Y\sim p\).
Both are computed via the disagreement-level decomposition
$$\mathbb{E}|\,\hat Y-Y\,|
= \sum_{d=0}^{k-1} d \;\mathbb{P}(|\hat Y-Y|=d),$$
where, for the uniform case,
$$\mathrm{OPD}_{UR}=\frac{1}{k}\sum_{d=0}^{k-1}
d\Big[\mathbb{P}\{Y\le k-d\}-\mathbb{P}\{Y\le d\} + \mathbb{P}\{Y\ge d+1\}\Big],$$
which is the discrete-\(\{1,\dots,k\}\) version of the expression shown in the manuscript.