const fieldName = "theme"; // Your field with linksconst oldPrefix = "Thoughts/01 Themes/";const newPrefix = "Digital Garden/Topics/";const relatedLinks = dv.current()[fieldName];if (Array.isArray(relatedLinks)) { // Map over the links, replace the path, and output only clickable links dv.el("span", relatedLinks .map(link => { if (link && link.path) { let newPath = link.path.startsWith(oldPrefix) ? link.path.replace(oldPrefix, newPrefix) : link.path; return dv.fileLink(newPath); } }) .filter(Boolean).join(", ") // Remove any undefined/null items );} else { dv.el(dv.current().theme);}
Efron-Stein Theorem
Let x1,…,xN be independent random variables and f any function of them. Then
Var(f)≤∑i=1NEx1,…,xi−1,xi+1,…xN[Varxi(f(x1,…,xi−1,xi,xi+1,…,xN))]
Remark
The only assumption that we make in the above is that
f:x1∈Σ1×⋯×xN∈ΣN→R
And the xi are independent.
NOTE
We generally want something to avoid taking these expectations
Proof
Let’s denote Ei:=Exi and E≤i:=Ex1,…,xi
\text{Var}(f) &= \mathbb{E}\left[f-\mathbb{E}\left[f\right]^2 \right] \\
&= \mathbb{E}\left[ (f-\cancel{ \mathbb{E}_{\leq 1}\left[f\right] } ) + \underbrace{ (\cancel{ \mathbb{E}_{\leq 1}\left[f\right] } - \cancel{ \mathbb{E}_{\leq 2}\left[f\right] } ) }_{ \mathbb{E}_{y_{1}}\left[f(y_{1},x_{2},\dots,x_{N})\right] -\mathbb{E}_{y_{1},y_{2}}\left[y_{1},y_{2},x_{3},\dots,x_{N}\right] }+\cancel{ \dots }+(\cancel{ \mathbb{E}_{\leq N-1}\left[f\right] } -\mathbb{E}_{\leq N}\left[f\right] )^2\right] \\
&
\end{align}$$
Expanding for the cross terms, if $i \leq j$, we get
$$\begin{align}
\mathbb{E}_{x_{1},\dots,x_{N}}&\left[\,(\mathbb{E}_{y_{1},\dots,y_{i}}\left[y_{1},\dots,y_{i},x_{i+1},\dots,x_{j},\dots,x_{N}\right]) \times(\mathbb{E}_{z_{1},\dots,z_{j}}\left[z_{1},\dots,z_{j},x_{j+1},\dots,x_{N}\right] ) \,\right] \\
&=\mathbb{E}\left[\,\mathbb{E}_{\leq j}\left[f\right] ^2\,\right]
\end{align}$$
Generally, $\mathbb{E}\left[\,\mathbb{E}_{\leq i}\left[f\right]\,\,\mathbb{E}_{\leq j}\left[f\right]\,\right]=\mathbb{E}_{}\left[(\mathbb{E}_{\leq\max\{ i,j \}}\left[f\right])^2\right]$
$$\begin{align}
&\mathbb{E}_{}\left[(\mathbb{E}_{\leq i}\left[f\right] -\mathbb{E}_{\leq i+1}\left[f\right] )\times(\mathbb{E}_{\leq j}\left[f\right] -\mathbb{E}_{\leq j+1}\left[f\right] )\right] \\
&= \mathbb{E}_{}\left[(\mathbb{E}_{\leq j}\left[f\right]) ^2\right] - \mathbb{E}_{}\left[(\mathbb{E}_{\leq j}\left[f\right])^2 \right] +\mathbb{E}_{}\left[(\mathbb{E}_{\leq j+1}\left[f\right] )^2\right] -\mathbb{E}_{}\left[(\mathbb{E}_{\leq j+1}\left[f\right] )^2\right] \\
&=0
\end{align}$$
By [[Jensen's inequality]]. So we get
$$\begin{align}
\text{Var}(f) &= \sum_{i=1}^N \mathbb{E}_{}\left[(\mathbb{E}_{\leq i-1}\left[f\right] -\mathbb{E}_{\leq i}\left[f\right] )^2\right] \\
&= \sum_{i=1}^N \mathbb{E}_{}\left[\mathbb{E}_{y_{1},\dots,y_{i-1}}\left[f(y_{1},\dots,y_{i-1},x_{i},\dots,x_{N})\right] -\mathbb{E}_{y_{i}}\left[f(y_{1},\dots,y_{i-1}, y_{i}, x_{i+1},\dots,x_{N})\right] \right] \\
(*)&\leq \sum_{i=1}^N \underbrace{ \mathbb{E}_{}\left[\mathbb{E}_{x_{i}}\left[f(x_{1},\dots,x_{N})\right] -\mathbb{E}_{y_{i}}\left[f(x_{1},\dots,x_{i-1}, y_{i}, x_{i+1},\dots x_{N})\right] \right] }_{ \text{Var}_{x_{i}}f(x) } \\
&= \sum_{i=1}^N \text{Var}_{x_{i}}(f(x))
\end{align}$$
Where we apply the inequality at $(*)$, and note that the $y_{i}$ are iid copies of the $x_i$ (and therefore can be interchanged freely, as convenient)
$$\tag*{$\blacksquare$}$$