Archive for Gemini

math that jaX [on the ‘Og]

Posted in Linux, pictures, University life with tags , , , , , , , , , , , on November 4, 2026 by xi'an

Two weeks ago, I got sufficiently annoyed by the poor rendering of the base WordPress interface for \{\LaTeX\) formulas and equations to search for an easy move to ennabling MathJax. A few exchanges with Claude, ChatGPT, and Gemini later, it appeared that the solution was quite simple had been available for quite a while (!), and consisted in loading the MathJax-LaTeX plugin in my WordPress site, provided I adopted a personal version for its primary. Which is why it is now xianblog.fr instead of xianblog.wordpress.com, still operational. (I would have preferred xianblog.eu ou xianblog.world, but these suffixes were not proposed.) As a result, readers may see more math in the posts, and a renewed majority of paper discussions!

For instance, here is Claude’s lengthy rendering of the posterior median being the optimal Bayes estimator under absolute error loss:

Let \(\theta\) have posterior distribution \(\pi(\theta \mid x)\), and assume \(\mathbb{E}[\,|\theta| \mid x\,] < \infty\) so that the posterior expected absolute error \[ \rho(a) = \mathbb{E}\big[\,|\theta – a| \;\big|\; x\,\big] \] is finite for every \(a \in \mathbb{R}\). A posterior median is any \(m\) such that \[ P(\theta \le m \mid x) \ge \frac{1}{2} \quad \text{and} \quad P(\theta \ge m \mid x) \ge \frac{1}{2}. \] Claim: For every \(a \in \mathbb{R}\), \(\rho(a) \ge \rho(m)\).

Proof Case 1: \(a > m\). Compare \(|\theta – a|\) and \(|\theta – m|\) on three regions:

\[
|\theta – a| – |\theta – m| =
\begin{cases}
(a – \theta) – (m – \theta) = a – m, & \theta \le m, \\[4pt]
(a – \theta) – (\theta – m) = a + m – 2\theta, & m < \theta < a, \\[4pt]
(\theta – a) – (\theta – m) = -(a – m), & \theta \ge a.
\end{cases}
\]

On the middle region, \(\theta < a\) gives \(a + m – 2\theta > a + m – 2a = -(a – m)\). So for all \(\theta\),

\[
|\theta – a| – |\theta – m| \;\ge\; (a – m)\Big[\mathbf{1}\{\theta \le m\} – \mathbf{1}\{\theta > m\}\Big].
\]

Taking posterior expectations, which is allowed because both sides are bounded by \(|a – m|\):

\[
\rho(a) – \rho(m) \;\ge\; (a – m)\Big[P(\theta \le m \mid x) – P(\theta > m \mid x)\Big]
= (a – m)\Big[2\,P(\theta \le m \mid x) – 1\Big].
\]

Since \(a – m > 0\) and \(P(\theta \le m \mid x) \ge \frac12\), the right-hand side is \(\ge 0\). Hence \(\rho(a) \ge \rho(m)\).

Case 2: \(a < m\). By the symmetric argument, with the roles of the left and right tails swapped,

\[
|\theta – a| – |\theta – m| \;\ge\; (m – a)\Big[\mathbf{1}\{\theta \ge m\} – \mathbf{1}\{\theta < m\}\Big], \] so \[ \rho(a) – \rho(m) \;\ge\; (m – a)\Big[2\,P(\theta \ge m \mid x) – 1\Big] \;\ge\; 0, \] using \(m – a > 0\) and \(P(\theta \ge m \mid x) \ge \frac12\).

Case 3: \(a = m\). This case is trivial.

Therefore

\[
m \in \arg\min_{a \in \mathbb{R}} \; \mathbb{E}\big[\,|\theta – a| \;\big|\; x\,\big].
\]