Archive for Claude

gerrymandering to the max

Posted in Books, Kids, pictures, Statistics with tags , , , , , , , , , , , , , , , on November 12, 2026 by xi'an

Another Fiddler puzzle on gerrymandering an electoral map when all the votes are already known. There are seven districts with identical population sizes and a party needs at least half of the votes to win a district.

What is the smallest total fraction of population needed to vote the gerrymanderer’s party to ensure winning a majority of the seven districts?

The minimal number of districts to secure is four, where at least half of the votes need be for this party, meaning that the extreme solution where no such votes are seen in the three other districts works out for only two out of seven voters are behind the gerrymanderer’s party!

The second puzzle asks for gerrymandering a map by choosing a set of probabilities \(p_1,\ldots,p_7\) of winning the corresponding districts, under the constraint that the average of these probabilities is \(\frac12\). Meaning that the overall population is balanced between both parties. What is the strategy maximising the chances of winning at least four of the seven districts? at least five? And what are these probabilities?

Setting two \(p_i\)’s to zero and all other five \(p_i\)’s to \(7/10\) leads to a dismal \((7/10)^5\) probability of getting five districts, worse than having \(\frac12\) for all districts. While setting three \(p_i\)’s to zero and all other four \(p_i\)’s to \(7/8\) leads to a \((7/8)^4\) that beats \(\frac12\). (The Fiddler calls the first option dummymandering since it produces the consequence opposite to the intended one! In the real, US, world, dummymandering happened for the midterms in most places the Republican majority redrew the maps, as in Texas, Ohio, NC, Florida, &tc, since the redistricting did not integrate the shift in voters’ preferences) I checked on Claude that this was the optimal allocation, with it backing the optimality on a result of Hoeffding (Annals of Mathematical Statistics, 1956) I had never heard of.

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].
\]

barred from entry!

Posted in Kids, pictures, University life with tags , , , , , , , , , , , , , on October 13, 2026 by xi'an

Tidy up, Claude!

Posted in Linux, Mountains, pictures, Statistics, Travel, University life with tags , , , , , , , , , , , , , , , , , on September 27, 2026 by xi'an

Nothing out of the ordinary there, but after years of procrastination at failing to update my publication webpage, following a wreckage by the default web composer on Ubuntu (and yours truly obviously!), I took advantage of the extra energy gained by my altitude night at the 5th station to ask Claude to update this page, with it replying it preferred to start from scratch (and from my LaTeX vita files). The only drawback is that many of the links introduced in the earlier version were not retrieved by the AI, despite my repeated request. On the plus side, trawling for missing entries and unpublished arXiv oldies but goldies, as well as adding mountain pictures (from the ‘Og!) proved much easier than the manual-by-keyboard approach. And I got an extra bonus in updating my LaTeX publication file and by creating the corresponding bibTeX file, all now available on my github page.

Round-robin (with Claude)

Posted in Books, Kids, R, Statistics, Wines with tags , , , , , , , , , , , , on August 15, 2026 by xi'an

A few days ago I had a coffee in Paris with my long-time friend (and former Statistics & Computing editor) Gilles Celeux, and he mentioned me stopping solving and posting maths puzzles like those weekly published by Le Monde. They have indeed vanished with the retirement of the authors, but Gilles added that the arrival of LLMs would have made the exercise moot. I disagreed as (i) the fun of solving the puzzle on my own  has not gone away and (ii) the pedagogical appeal of the puzzle and its resolution remains. As the next Fiddler puzzle arrived in my mailbox, my resolution was put to the test (contrariwise to the previous entry, which did not require massive computations):

The Fiddler League consists of two teams. Over a season, they play each other 162 times. Each team has an equal chance of winning each game, and the results of games are independent. Over the season, on average, how many games would you expect the team with the better record to have won?

I started on the wrong foot with E[X|X≥81] when X is Bin(162,½), equal to 85.77 (either directly or with a Normal approximation), which differs from my second thought, E[max(X,162-X)]=86.07 (either directly or with a Normal approximation), which is larger because of the reflection produced by max. While the first computation was manageable, the second one seemed to involve simulation and I caved in prompting Claude, which provided the answer along with the connection

E[max(X,162−X)]=E[X∣X≥81](1+p81​)−81p81​

After some expansion, the League boasts 30 teams. Over a season, each team plays each other team five times. (Each team plays a total of 145 games.) Again, each team has an equal chance of winning each game, and the results of games are independent. Over the season, on average, how many games would you expect the team with the best record to have won?

The best record is max(Xi) with each of the 30 Xi‘s a sum of 29 Yij and the Yij=5-Yji distributed as Bin(5,½). The Xi‘s are thus Bin (145,½) but dependent. While I could not figure out a closed form answer for the expectation, a direct Monte Carlo resolution is obviously feasible, with Claude (rather than me) running it over 400 million repetitions, but a 30 dimensional Normal approximation exploiting the correlation of 1/29 between the components leads to roughly 85 as the expected value. (Again computed by a Claudicant simulation.)

While the conclusion that the Normal approximation is pretty accurate with so many terms in the Binomial variates is quite unsurprising, Claude saves me coding time without ruining the puzzle altogether. (And Gemini made me aware that the name of the café where Gilles and I regularly meet, L’Écir, is an Auvergne noun for a local, dangerous, mountain blizzard! Thus linking the place to the foundation of the café by Auvergne expatriates…)