<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://mpaldridge.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://mpaldridge.github.io/" rel="alternate" type="text/html" /><updated>2026-07-02T09:00:49+00:00</updated><id>https://mpaldridge.github.io/feed.xml</id><title type="html">Matthew Aldridge</title><subtitle>The website of Dr Matthew Aldridge, Lecturer in Statistics at the University of Leeds</subtitle><entry><title type="html">A (more) probabilistic proof of a geometric result</title><link href="https://mpaldridge.github.io/blog/marions-theorem.html" rel="alternate" type="text/html" title="A (more) probabilistic proof of a geometric result" /><published>2026-07-01T00:00:00+00:00</published><updated>2026-07-01T00:00:00+00:00</updated><id>https://mpaldridge.github.io/blog/marions-theorem</id><content type="html" xml:base="https://mpaldridge.github.io/blog/marions-theorem.html"><![CDATA[<p>Here’s a cute little paper: it’s called <a href="https://arxiv.org/abs/2606.02087">“Generalization of Marion’s theorem: volumes of central polytopes obtained by trisecting the edges of simplices”</a> by Yu. V. Kazakov.</p>

<p>Marion’s theorem is a simple geometric theorem about triangles. For each side of the triangle, trisect the side and connect the two trisection points to the opposite corner. This gives you a hexagon in the middle of the triangle, as shown in <a href="https://commons.wikimedia.org/wiki/File:Théorème_de_Marion.png">this picture</a>:</p>

<p><img src="../assets/img/marion.png" alt="" /></p>

<p>Marion’s theorem (after <a href="https://mathshistory.st-andrews.ac.uk/Biographies/Walter/">Marion Walter</a>) states that the area of this central hexagon is one-tenth the area of the original triangle.</p>

<p>Kazakov’s result is a multidimensional generalisation of this. You can read the paper itself for details of the construction, but the result is that, in $n$ dimensions, the central polytope has volume $1/\binom{2n+1}{n}$ the volume of the original simplex. Marion’s theorem is the $n = 2$ case, for which $\binom{5}{2}$ does indeed equal 10.</p>

<p>But this paper interested me because it reduces the problem to a purely probabilistic one. Again, see the paper for details of why the reduction holds, but the probabilistic setup is this: Let $Y_0, Y_1, \dots, Y_n$ be $n+1$ IID exponentially distributed random variables. What is the probability that the ratio of the largest of the $Y_k$s to the smallest of the $Y_k$s is at most 2? That is, what’s the probability the largest is no more than twice as big as the smallest? The answer to this question is, Kazakov explains, the same as the ratio of the volumes of the two shapes.</p>

<p>The paper calculates this probability “by hand”: it writes down the relevant integral, expands some brackets usng the binomial theorem, calculates the integral as a sum involving binomial coefficients, and cites some combinatorial result that expresses that sum as $1/\binom{2n+1}{n}$. This is fine – but, speaking as a probabilist, I felt like I wanted a more “genuinely probabilistic” argument, that better explains <em>why</em> the answer is $\binom{2n+1}{n}$. The purpose of this blogpost is to record such a proof.</p>

<p>We start off with $n+1$ exponential alarm clocks $Y_0, Y_1, \dots, Y_n$. Eventually one of the alarm clocks rings – let’s say it’s at time $Y^*$ – and that’s the first alarm clock.</p>

<p>At this point, we can take advantage of the memoryless property of the exponential distribution. So, after this first ring, the remaining $n$ alarm clocks can reset themselves to $n$ new exponential distributions $Z_1, \dots, Z_n$. For the ratio of the last alarm clock time to the first alarm clock time to be at most 2, all these new alarm clocks must ring before another $Y^*$ seconds are up.</p>

<p>So in order to “succeed”, the $n$ new reset alarm clocks $Z_1, \dots, Z_n$ must all be shorter than the shortest of the $n+1$ original alarm clocks; that is, shorter than all $n+1$ of those original alarm clocks $Y_0, Y_1, \dots, Y_n$. In other words, of the $2n + 1$ alarm clocks,</p>

\[Y_0, Y_1, \dots, Y_n, Z_1, \dots, Z_n\]

<p>we need the longest $n+1$ of them to be in the first $n+1$ places and the shortest $n$ of them to be in the last $n$ places. Of the $2n+1$ positions, the shortest $n$ will occupy a subset of $n$ of those positions; 1 of the $\binom{2n+1}{n}$ such subsets is the last $n$ positions, so the probability is $1/\binom{2n+1}{n}$.</p>]]></content><author><name></name></author><category term="maths" /><summary type="html"><![CDATA[Here’s a cute little paper: it’s called “Generalization of Marion’s theorem: volumes of central polytopes obtained by trisecting the edges of simplices” by Yu. V. Kazakov.]]></summary></entry><entry><title type="html">Guardian 100 best novels (stats and errors)</title><link href="https://mpaldridge.github.io/blog/guardian-novels.html" rel="alternate" type="text/html" title="Guardian 100 best novels (stats and errors)" /><published>2026-05-17T00:00:00+00:00</published><updated>2026-05-17T00:00:00+00:00</updated><id>https://mpaldridge.github.io/blog/guardian-novels</id><content type="html" xml:base="https://mpaldridge.github.io/blog/guardian-novels.html"><![CDATA[<p><img src="../assets/img/guardian-100.jpg" alt="" /></p>

<p>I have been enjoying reading through (and arguing with!) the Guardian’s <a href="https://www.theguardian.com/books/ng-interactive/2026/may/12/the-100-best-novels-of-all-time">100 best novels list</a>. You can see the whole top 100 at that link, but the top 10 is this:</p>

<ol>
  <li>Middlemarch by George Eliot</li>
  <li>Beloved by Toni Morrison</li>
  <li>Ulysses by James Joyce</li>
  <li>To the Lighthouse by Virginia Woolf</li>
  <li>In Search of Lost Time by Marcel Proust</li>
  <li>Anna Karenina by Leo Tolstoy</li>
  <li>War and Peace by Leo Tolstoy</li>
  <li>Jane Eyre by Charlotte Brontë</li>
  <li>The Great Gatsby by F Scott Fitzgerald</li>
  <li>Pride and Prejudice by Jane Austen</li>
</ol>

<p>On <a href="https://www.theguardian.com/books/ng-interactive/2026/may/12/the-100-best-novels-of-all-time">that page</a>, you can also click through to see all the voters and which 10 books each of them voted for. So I thought it would be fun to do a bit of statistical messing around with the votes and see what I could find out. With a bit of rootling around you can find <a href="https://interactive.guim.co.uk/atoms/2026/03/2026-best-100-books-testing/best-100-books/v/1778864974/app.js">this file</a>, and then – in my case, with help from GPT – you can extract all the voting data. (To save anyone else the effort, you can find that voting data in a much more pleasant CSV file <a href="https://github.com/mpaldridge/guardian-100-novels/">here, on my Github</a>.)</p>

<h2 id="scoring-system">Scoring system</h2>

<p>The first task I set myself was to work out how the raw votes were used to compile the top 100. The Guardian doesn’t say exactly how this was done, but in <a href="https://www.theguardian.com/books/2026/may/12/tell-us-what-are-your-top-three-novels-of-all-time">this article</a> we get a hint: “We scored the titles according to how often they were voted for, and then added a weighting based on individual rankings.”</p>

<p>I tried a mixture of guesswork and machine optimisation, but I could never get a system that <em>exactly</em> matched the Guardian’s top 100. In particular, no matter what I tried, My Ántonia by Willa Cather, which is #100 on the Guardian list, kept coming out somewhere around the mid-70s, messing everything up. I now think this is an error – see more on that below – but if I ignore that one book, I can get a match on the rest.</p>

<p>So it looks to me that the scoring method is this:</p>

<ul>
  <li>A book gets 20 points for being mentioned on a list at all.</li>
  <li>The book then gets extra points for how high it is on the list: 1 extra point for tenth, 2 extra points for ninth, and so on, up to 10 extra points for first.</li>
  <li>So overall, the scores are 21 for tenth, 22 for ninth, up to 30 for first.</li>
</ul>

<p>The scoring method might not <em>exactly</em> be this – you can probably change the 20 a bit and still get equivalent results. (And of course you can scale the scores by some constant factor without changing anything.) But I’m fairly sure the true scoring method must be pretty close to this.</p>

<p>This method does give a few tied results, which, if my scoring hunch is correct, the Guardian must have decided some way to break. It doesn’t make much difference, though: the first tie is that Blood Meridian by Cormac McCarthy, Crime and Punishment by Fyodor Dostoevsky, and Jude the Obscure by Thomas Hardy are all joint 68th. Also, A Portrait of the Artist as a Young Man misses out on the top 100 on the tie-breaker alone: it’s joint 98th along with three other books that made it onto the list.</p>

<h2 id="errors">Errors</h2>

<p>I think the Guardian has made two errors in compiling the votes into the top 100.</p>

<p>This first is <strong>My Ántonia</strong>. That got four votes; under my scoring – which I think is their scoring too – this gives it 100 points, enough to put it joint 75th, alongside The Bluest Eye by Toni Morrison, Dracula by Bram Stoker, and The Rainbow by DH Lawrence. But in the Guardian’s list it’s #100, the last book to make it onto the list. My suspicion is is that Tahmima Anam’s tenth-place vote for My Ántonia somehow got ignored. That vote gave the book 20 points for being included, plus 1 point for being tenth; without it, the book’s score goes down from 100 to 79, which moves it down from joint-75th to joint-97th, consistent with its ranking of 100.</p>

<p>The second problem is the book by Albert Camus called <strong>L’Étranger</strong> in French. Its title has been translated as both The Stranger (more common in the US) and The Outsider (more common in the UK). “The Stranger” received two votes, for 51 points, and “The Outsider” also received two votes, for 52 points. Individually, neither of these are enough to get on the list – but, merged together, 103 points for The Stranger/Outsider is enough to catapult it up to 71st place, between Jude the Obscure by Thomas Hardy and Kindred by Octavia E Butler.</p>

<p><strong>Update:</strong> <em><a href="https://www.theguardian.com/news/2026/may/23/corrections-and-clarifications">The Guardian’s corrections and clarifications column</a> has acknowledged these mistakes (I don’t know whether indirectly from this post?), but they aren’t changing the list:</em></p>

<blockquote>
  <p>A production error meant Albert Camus’s The Outsider was omitted from our top 100 novels list; its intended placing was 71. Also, My Ántonia should have been 78, not 100 […] The rankings remain as first published but with the errata acknowledged here.</p>
</blockquote>

<p><strong>Update to the update:</strong> <em>Actually the Guardian</em> has <em>decided to update the ranking to correct the errors. The Outsider is in at 71; My Ántonia rises to 78 (behind The Bluest Eye and Dracula but ahead of The Rainbow, for whatever tie-breakery reasons). The Go-Between by LP Hartley is unceremoniously shunted out of the top 100. I haven’t changed anything else in this blogpost to take these updates into account, because I can’t be bothered, but I suppose various rankings I mention are going to be out by a couple of places here and there.</em></p>

<h2 id="bubbling-under">Bubbling under</h2>

<p>The first fun thing I wanted to with the data was to see which books were just outside the top 100. The following are all the books that received three votes and that missed out only on placings within voters’ lists:</p>

<ul>
  <li>Missing out on the top 100 only by the Guardian’s tie-break:
    <ul>
      <li>A Portrait of the Artist as a Young Man by James Joyce</li>
    </ul>
  </li>
  <li>Joint 103rd:
    <ul>
      <li>Love in the Time of Cholera by Gabriel García Márquez</li>
      <li>The Years by Annie Ernaux</li>
      <li>The Lord of the Rings by J.R.R. Tolkien</li>
      <li>To Kill a Mockingbird by Harper Lee</li>
      <li>Light in August by William Faulkner</li>
    </ul>
  </li>
  <li>Joint 108th
    <ul>
      <li>The Mirror and the Light by Hilary Mantel</li>
      <li>Robinson Crusoe by Daniel Defoe</li>
      <li>The Name of the Rose by Umberto Eco</li>
      <li>The Summer Book by Tove Jansson</li>
    </ul>
  </li>
  <li>Joint 112th:
    <ul>
      <li>Barchester Towers by Anthony Trollope</li>
      <li>A Dance to the Music of Time by Anthony Powell</li>
      <li>Drive Your Plow Over the Bones of the Dead by Olga Tokarczuk</li>
      <li>The Blue Flower by Penelope Fitzgerald</li>
      <li>Alice’s Adventures in Wonderland by Lewis Carroll (credit to <a href="https://bsky.app/profile/rayburnmaarup.bsky.social/post/3mmby3qgkhk22">Steffen Rayburn-Maarup</a>, who noticed that one of these votes appeared under the title “Alice in Wonderland”)</li>
    </ul>
  </li>
  <li>Joint 117th:
    <ul>
      <li>How to Be Both by Ali Smith</li>
      <li>Money by Martin Amis</li>
      <li>A Month in the Country by JL Carr (<a href="https://bsky.app/profile/rayburnmaarup.bsky.social/post/3mmby3qgkhk22">Rayburn-Maarup</a> again – the author’s name was inconsistent in the data)</li>
    </ul>
  </li>
  <li>120th:
    <ul>
      <li>American Pastoral by Philip Roth</li>
    </ul>
  </li>
  <li>Joint 121st:
    <ul>
      <li>Huckleberry Finn by Mark Twain</li>
      <li>The Grapes of Wrath by John Steinbeck</li>
      <li>Sense and Sensibility by Jane Austen</li>
      <li>The House of Mirth by Edith Wharton</li>
    </ul>
  </li>
  <li>Joint 125th:
    <ul>
      <li>Infinite Jest by David Foster Wallace</li>
      <li>The Tale of Genji	by Murasaki Shikibu</li>
      <li>Villette by Charlotte Brontë</li>
    </ul>
  </li>
  <li>128th:
    <ul>
      <li>Herzog by Saul Bellow</li>
    </ul>
  </li>
  <li>129th:
    <ul>
      <li>Septology by Jon Fosse</li>
    </ul>
  </li>
  <li>Joint 130th:
    <ul>
      <li>The Catcher in the Rye by J. D. Salinger</li>
      <li>Underworld by Don DeLillo</li>
    </ul>
  </li>
  <li>132nd
    <ul>
      <li>The Death of the Heart by Elizabeth Bowen</li>
    </ul>
  </li>
</ul>

<p>The Death of the Heart got three tenth-place votes. The highest ranked book to get two votes was NW by Zadie Smith, with one first-place and one second-place vote.</p>

<p><a href="https://bsky.app/profile/rayburnmaarup.bsky.social/post/3mmby3qgkhk22">Steffen Rayburn-Maarup</a> also notes that if the two votes for A Wizard of Earthsea by Ursula K Le Guin (the first novel in the Earthsea cycle) were merged with the vote for “Earthsea” (which I would assume is a vote for the cycle of novels as a whole), that would be joint 103rd too.</p>

<h2 id="best-novelists">Best novelists</h2>

<p>Another fun one: who are the best novelists? To make this list, I just added up the scores from all each author’s books. Virginia Woolf now jumps over George Eliot to claim the top spot.</p>

<p>The top 10 authors, together with their scores, and their books (most popular first) that received at least two votes, are these:</p>

<ol>
  <li>Virginia Woolf (1687): To the Lighthouse, Mrs Dalloway, Orlando, The Waves, Jacob’s Room, A Room of One’s Own</li>
  <li>George Eliot (1669): Middlemarch, Daniel Deronda</li>
  <li>Jane Austen (1650): Pride and Prejudice, Emma, Persuasion, Mansfield Park, Sense and Sensibility</li>
  <li>Toni Morrison (1501): Beloved, Song of Solomon, The Bluest Eye, Sula</li>
  <li>Leo Tolstoy (1319): Anna Karenina, War and Peace</li>
  <li>Charles Dickens (1149): Bleak House, David Copperfield, Great Expectations, Our Mutual Friend</li>
  <li>James Joyce (1075): Ulysses, A Portrait of the Artist as a Young Man</li>
  <li>Marcel Proust (741): In Search of Lost Time</li>
  <li>Henry James (731): The Portrait of a Lady, The Golden Bowl, The Turn of the Screw, The Ambassadors</li>
  <li>Vladimir Nabokov (697): Lolita, Pale Fire, Pnin</li>
</ol>

<p>Many authors had enough points to make it onto the top 100 list, if only their voters had been able to converge on which book to choose. The top 10 novelists of those not represented in the top 100 novels are these:</p>

<ul>
  <li>John Steinbeck (178): The Grapes of Wrath, Cannery Row, East of Eden</li>
  <li>Don DeLillo (170): Underworld</li>
  <li>Saul Bellow (158): Herzog, The Adventures of Augie March</li>
  <li>Anthony Trollope (130): Barchester Towers</li>
  <li>Angela Carter (129): Nights at the Circus, Wise Children</li>
  <li>Iris Murdoch (129): five books with one vote each</li>
  <li>Penelope Fitzgerald (127): The Blue Flower, The Beginning of Spring</li>
  <li>Evelyn Waugh (121): A Handful of Dust</li>
  <li>Abdulrazak Gurnah (120): Afterlives, Paradise</li>
  <li>John Updike (119): the Rabbit omnibus got a vote, as did three of its constituent parts</li>
</ul>

<p>Plus Albert Camus (157: The Outsider/Stranger, The Plague), who should have been on the list already anyway.</p>

<h2 id="alternative-scoring-methods">Alternative scoring methods</h2>

<p>The scoring method adopted here isn’t the only way to convert votes to a ranking. I thought it might be interesting to see how other ways of scoring would change the results.</p>

<p>The main axis along which to compare scoring methods is what I shall call “aggressiveness”. An aggressive scoring method gives big rewards for being at the top of someone’s list and very little credit for being down towards the nine/ten area; while a non-aggressive scoring method gives a big reward for being on someone’s list at all, but only a very small extra reward for being high on that list. It seemed to make sense to look at the two extremes of this axis.</p>

<h3 id="aggressive-scoring">Aggressive scoring</h3>

<p>The maximally aggressive method is simply to rank on the number of #1 votes – how many people said this was their favourite novel. If two books are tied on #1 votes, you then look at #2 votes, and so on.</p>

<p>Under this method, the top 10 changes to this:</p>

<ol>
  <li>Middlemarch by George Eliot (19 #1s, no change)</li>
  <li>Ulysses by James Joyce (13 #1s, up 1)</li>
  <li>Anna Karenina by Leo Tolstoy (7 #1s, up 3)</li>
  <li>Beloved by Toni Morrison (7 #1s, down 2)</li>
  <li>War and Peace by Leo Tolstoy (7 #1s, up 2)</li>
  <li>In Search of Lost Time by Marcel Proust (6 #1s, down 1)</li>
  <li>Wuthering Heights by Emily Brontë (6 #1s, up 13)</li>
  <li>To the Lighthouse by Virginia Woolf (5 #1s, down 4)</li>
  <li>Don Quixote by Miguel de Cervantes (5 #1s, up 17)</li>
  <li>Moby-Dick by Herman Melville (4 #1s, up 5)</li>
</ol>

<p>Some of the big risers up the list on this method include:</p>

<ul>
  <li>Jacob’s Room by Virginia Woolf (29th, up 61)</li>
  <li>Catch-22 by Joseph Heller (39th, up 58)</li>
  <li>The Road by Cormac McCarthy (47th, up 51)</li>
  <li>Life and Fate by Vasily Grossman (43rd, up 48)</li>
  <li>Invisible Cities by Italo Calvino (46th, up 47)</li>
</ul>

<p>Many books that had two or three total votes, one of which was a #1 vote, failed to make the original top 100 but would make the aggressively scored 100. These include:  </p>

<ul>
  <li>NW by Zadie Smith</li>
  <li>The Enigma of Arrival by V. S. Naipaul</li>
  <li>The Years by Annie Ernaux</li>
  <li>Cannery Row by John Steinbeck</li>
  <li>The Lord of the Rings by J.R.R. Tolkien</li>
</ul>

<h3 id="gentle-scoring">Gentle scoring</h3>

<p>We could also look at minimally aggressive scoring. Here, we just rank on total number of votes. Given a tie, we then look at total number of votes if participants were invited to list only 9 books, and so on.</p>

<p>Now, the Guardian’s method is already pretty tame – 21 points for being on a list at all, with only a maximum of 9 more based on position – so this doesn’t change the list very much at all. But, for the record the top 10 would be this:</p>

<ol>
  <li>Middlemarch by George Eliot (56 votes, no change)</li>
  <li>Beloved by Toni Morrison (43 votes, no change)</li>
  <li>Ulysses by James Joyce (36 votes, no change)</li>
  <li>To the Lighthouse by Virginia Woolf (31 votes, no change)</li>
  <li>In Search of Lost Time by Marcel Proust (27 votes, no change)</li>
  <li>Anna Karenina by Leo Tolstoy (26 votes, no change)</li>
  <li>Jane Eyre by Charlotte Brontë (21 votes, up 1)</li>
  <li>War and Peace by Leo Tolstoy (20 votes, down 1)</li>
  <li>The Great Gatsby by F Scott Fitzgerald (20 votes, up 3)</li>
  <li>Pride and Prejudice by Jane Austen (20 votes, down 1)</li>
</ol>

<p>One book, Love in the Time of Cholera by Gabriel García Márquez, would enter the top 100. There are no huge moves, although maybe A Farewell to Arms by Ernest Hemingway and The Vegetarian by Han Kang would rise a few spots.</p>

<h2 id="weirdest-and-least-weird-ballots">Weirdest and least-weird ballots</h2>

<p>The voter who was most representative of the electoral college as a whole was Eimear McBride, narrowly beating Siri Hustvedt – at least by one way of measuring representative-ness that I can’t be bothered to get into right now. McBride voted for five out of the top six on the final list; her full ballot was as follows:  </p>

<ol>
  <li>Ulysses by James Joyce (#3)</li>
  <li>Crime and Punishment by Fyodor Dostoevsky (#69)</li>
  <li>Middlemarch by George Eliot (#1)</li>
  <li>In Search of Lost Time by Marcel Proust (#5)</li>
  <li>Wuthering Heights by Emily Brontë (#20)</li>
  <li>The Magic Mountain by Thomas Mann (#42)</li>
  <li>To the Lighthouse by Virginia Woolf (#4)</li>
  <li>Anna Karenina by Leo Tolstoy (#6)</li>
  <li>Nineteen Eighty-Four by George Orwell (#16)</li>
  <li>Moby-Dick by Herman Melville (#15)</li>
</ol>

<p>The most idiosyncratic voter was Nussaibah Younis – only one of the books on her ballot was voted for by someone else, and even that book only once.  Her ballot was as follows:  </p>

<ol>
  <li>The Song of Achilles by Madeline Miller (only vote)</li>
  <li>Detransition, Baby by Torrey Peters (only vote)</li>
  <li>The Trees by Percival L. Everett (only vote)</li>
  <li>The Sellout by Paul Beatty (#201)</li>
  <li>Vernon Subutex 1 by Virginie Despentes (only vote)</li>
  <li>Love Me Tender by Constance Debré (only vote)</li>
  <li>Big Swiss by Jen Beagin (only vote)</li>
  <li>Mammoth by Eva Baltasar (only vote)</li>
  <li>A Long Way Down by Nick Hornby (only vote)</li>
  <li>We All Want Impossible Things by Catherine Newman (only vote)</li>
</ol>

<p>(This is a correction – I earlier awarded this to Nikesh Shukla, who actually had the fifth-weirdest ballot.)</p>

<h2 id="my-ballot">My ballot</h2>

<p>No one asked, but my votes would be:</p>

<ol>
  <li>The Great Gatsby by F Scott Fitzgerald (#11)</li>
  <li>One Hundred Years of Solitude by Gabriel García Márquez (#17)</li>
  <li>Nineteen Eighty-Four by George Orwell (#16)</li>
  <li>The Metamorphosis by Franz Kafka (#48)</li>
  <li>The Outsider/Stranger by Albert Camus (should have been #71)</li>
  <li>The Unbearable Lightness of Being by Milan Kundera (#490)</li>
  <li>Alice’s Adventures in Wonderland by Lewis Carroll (#112)</li>
  <li>A Clockwork Orange by Anthony Burgess (no votes)</li>
  <li>The Sun Also Rises by Ernest Hemingway (#226)</li>
  <li>The Road by Cormac McCarthy (#98)</li>
</ol>

<p>I declined Chronicle of a Death Foretold and The Old Man and the Sea, which I might slightly prefer to their heftier siblings, on the grounds that they are more novellas than novels. But then broke that rule to allow The Metamorphosis. I feel a bit bad these are all by men – Play It As It Lays by Joan Didion (no votes) nearly made it. And is Alice in Wonderland really a <em>novel</em> exactly, anyway? Perhaps not. Although if it is, why couldn’t I have counted Charlie and the Chocolate Factory too…</p>]]></content><author><name></name></author><category term="maths," /><category term="notmaths" /><summary type="html"><![CDATA[]]></summary></entry><entry><title type="html">The multiset coefficient deserves more respect!</title><link href="https://mpaldridge.github.io/blog/multiset-coefficient.html" rel="alternate" type="text/html" title="The multiset coefficient deserves more respect!" /><published>2026-03-09T00:00:00+00:00</published><updated>2026-03-09T00:00:00+00:00</updated><id>https://mpaldridge.github.io/blog/multiset-coefficient</id><content type="html" xml:base="https://mpaldridge.github.io/blog/multiset-coefficient.html"><![CDATA[<p><strong>Being the second in a series of blogposts quite unnecessarily scolding the reader about the binomial coefficient</strong> (Previously: <a href="binomial.html">“Don’t write the binomial coefficient as n! / k! (n-k)!”</a>)</p>

<p>The binomial coefficient</p>

\[\binom{n}{k} = \frac{n^{\underline{k}}}{k!} = \frac{n(n-1)\cdots(n-k+1)}{k!}\]

<p>counts the number of ways in which you can choose $k$ objects from a set of $n$ objects. How many ways can I pick a team of $k$ players from a squad of $n$ players? How many hands of $k$ cards could I deal from a deck of $n$ cards. How many different lottery tickets of $k$ numbers are there using the numbers from 1 to $n$?</p>

<p>Importantly, each object can appear at most once: you can’t choose the same player to play twice in the team, or the have same card appear twice in your hand, or choose the same number twice on your lottery ticket.</p>

<p>But sometimes we are interested in choosing $k$ objects from a set of $n$ objects where each object can appear multiple times. How many boxes of $k$ chocolates can be made from a range of $n$ varieties? In how many ways can $k$ small balls be placed into $n$ large boxes? In how many ways can $k$ identical tasks be assigned to $n$ workers?</p>

<p>How can we count these? If you ask a mathematician, they will probably tell you that these can still be counted using the binomial coefficient, just slightly differently. The number of sets with multiplicity – called <em>multisets</em> – is the slightly different binomial coefficient $\binom{n+k-1}{k}$, with $n+k-1$, rather than just $n$, on the top.</p>

<p>There’s a famously elegant method to show that this binomial coefficient counts the number of multisets, called the “stars and bars” construction. Think of the “$k$ balls into $n$ boxes” application. Let’s take $n = 5$ boxes and $k = 7$ balls. We can picture the $n = 5$ boxes by drawing $n - 1 = 4$ bars:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    |     |     |     |    
</code></pre></div></div>

<p>This creates $n = 5$ boxes: the first box is to the left of the first bar; the second box is between the first and second bars; the third box in between the second and third bars; the fourth box in between the third and fourth bars; and the fifth and final box is to the right of the fourth bar.</p>

<p>We can then denote which boxes the balls fall into by using a star to mark each ball.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> ** |     | *** |  *  |  *     
</code></pre></div></div>

<p>This denotes that there are two balls in the first box, no balls in the second box, three balls in the third box, and one each in the fourth and fifth boxes.</p>

<p>We can now even up the unequal gaps in the pattern to leave:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> * * | | * * * | * | *
</code></pre></div></div>

<p>In total we have a pattern of $n + k - 1 = 11$ symbols: $n - 1 = 4$ bars and $k = 7$ stars. Any such pattern of $n + k - 1$ symbols ($k$ stars and $n - 1$ bars) corresponds to a multiset. So the number of multisets is the numbers of ways to places $k$ stars among $n - k + 1$ positions, which is $\binom{n-k+1}{k}$.</p>

<p>The fact that both normal sets and multisets are both counted by the binomial coefficient (in slightly different ways) is very convenient, this mathematician would probably say. You only have to learn one thing! Whenever you are dealing with multisets, you can just switch immediately to binomial coefficients, and use all the useful facts you already know about the binomial coefficient to help with your maths problem.</p>

<p>But I don’t really like this. It makes the “multiset coefficient” (as I will call it) merely an appendage to the much more important binomial coefficient, unworthy of study in its own right. But I want to raise the status of the multiset coefficient, to value it an equally cherished sibling of the binomial coefficient!</p>

<p>To do this, I’m going to start by giving the multiset coefficient its own notation and algebraic definition. Then I want to go through some of the identities involving the binomial coefficient and give multiset coefficient equivalents of those results – not merely by substituting $\binom{n-k+1}{k}$ into the already-existing binomial identity to give a simple multiset corollary, but rather by taking the logical argument behind the binomial identity and applying it anew to the multiset situation, then seeing what is produced by that analysis.</p>

<h3 id="1-notation">1. Notation</h3>

<p>There does not seem to be a universally recognised notation for the multiset coefficient, but Richard Stanley (author of the legendary <em>Enumerative Combinatorics</em> textbook, which deals with this sort of thing) suggests</p>

\[{\bigg(\kern-0.4em\dbinom{n}{k}\kern-0.4em\bigg)}\]

<p>– like the binomial coefficient, but with double brackets. If it’s good enough for Prof Stanley, it’s good enough for me.</p>

<p>In speech, the binomial coefficient $\binom{n}{k}$ is said as “$n$ choose $k$”. Stanley proposes that $\big(\kern-0.2em\tbinom{n}{k}\kern-0.2em\big)$ should be “$n$ multichoose $k$”, which I also like.</p>

<h3 id="2-algebraic-definition">2. Algebraic definition</h3>

<p>As we know, the binomial coefficient can be calculated with the expression</p>

\[\binom{n}{k} = \frac{n^{\underline{k}}}{k!} = \frac{n(n-1)\cdots(n-k+1)}{k!} .\]

<p>The argument here is that the “falling factorial” $n^{\underline{k}} = n(n-1)\cdots(n-k+1)$ in the numerator is the number of ways to count sets where the order <em>does</em> matter, then dividing $k!$ compensates for each set having been chosen in $k!$ different orders.</p>

<p>The equivalent expression for the multiset coefficient is</p>

\[{\bigg(\kern-0.4em\dbinom{n}{k}\kern-0.4em\bigg)} = \frac{n^{\overline{k}}}{k!} = \frac{n(n+1)\cdots(n+k-1)}{k!} .\]

<p>Again, this can be justified by the numerator – here a “rising factorial” $n^{\overline{k}} = n(n+1)\cdots(n+k-1)$ – being the count of the multisets where the order matters, and the denominator $k!$ allowing for the different orderings.</p>

<p>Why do we get this rising factorial when the order matters? I like to think of hanging $k$ flags on $n$ flagpoles:</p>

<ul>
  <li>
    <p>The first flag has $n$ choices: it can go on any of the $n$ flagpoles.</p>
  </li>
  <li>
    <p>The second flag now has $n+1$ choices: either it goes on one of the $n - 1$ empty flagpoles, or it goes on the same pole as the first flag, in which case it can either go above the first flag or below it. Over all, that’s $(n-1) + 2 = n+1$ choices.</p>
  </li>
  <li>
    <p>The third flag has $n+2$ choices. If the first two flags went on different poles, we have $n-2$ empty flagpoles, above or below the first flag, and above or below the second flag, making $(n-2) + 2 + 2 = n+2$. If the first two flags went on the same pole, we have $n-1$ empty poles, or the busy pole: above both flags, in between them, or below both flags; that’s $(n-1)+3 = n+2$ as well.</p>
  </li>
</ul>

<p>As we go, each flag creates an extra space, either by splitting an empty pole into “above or below the new flag”, or by splitting the “bit of pole” it gets attached to into directly above or directly below the new flag. Hence we get $n^{\overline{k}} = n(n+1)\cdots(n+k-1)$ multisets where the order matters. Dividing by the $k!$ orderings of the flags gives the expression we were after.</p>

<h3 id="3-a-special-item">3. A special item</h3>

<p>The most famous identity involving the binomial coefficient is Pascal’s formula:</p>

\[\binom{n}{k} = \binom{n-1}{k} + \binom{n-1}{k-1} .\]

<p>To decide what the multiset coefficient equivalent of this is, we’ll have to think about what it shows. Statements like these are best proven using a “double counting” argument: that is, you show that both sides of the equation are counting the same thing in different ways.</p>

<p>Here, the left-hand side $\binom{n}{k}$ is, of course, just the number of ways of choosing $k$ items from $n$ items. Suppose one of the objects is “special” somehow; then we can count separately the number of sets that don’t include the special item and those that do include the special item. If the special item isn’t included, then we need to pick all $k$ items from the $n-1$ non-special items, which can be done in $\binom{n-1}{k}$ ways. If the special item is included, then we only need $k-1$ more of the $n-1$ non-special items, which can be done in $\binom{n-1}{k-1}$ ways. Adding these two together gives the right-hand side.</p>

<p>Almost the same argument works with the multiset coefficient. If the special item isn’t included, then we need to pick all $k$ items from the $n-1$ non-special items, which can be done in $\big(\kern-0.2em\tbinom{n-1}{k}\kern-0.2em\big)$ ways. If the special item is included, then we only need $k-1$ more items – but there are still $n$ choices, not $n-1$, because we’re allowed to pick yet more of the special item, so this gives $\big(\kern-0.2em\tbinom{n}{k-1}\kern-0.2em\big)$.</p>

<p>The multiset coefficient version of Pascal’s formula is therefore</p>

\[{\bigg(\kern-0.4em\dbinom{n}{k}\kern-0.4em\bigg)} = {\bigg(\kern-0.4em\dbinom{n-1}{k}\kern-0.4em\bigg)} + {\bigg(\kern-0.4em\dbinom{n}{k-1}\kern-0.4em\bigg)} .\]

<h3 id="4-a-boss">4. A boss</h3>

<p>What about this binomial coefficient identity:</p>

\[k\binom{n}{k} = n \binom{n-1}{k-1} .\]

<p>This counts the number of ways of picking a board of $k$ people from an office of $n$ employees, with one of those people being the boss of the board. We can pick the board in $\binom{n}{k}$ ways, then promote one of those $k$ board-members to be the boss, giving the left-hand side. Alternatively, we can pick one of the $n$ employees to be the boss, then fill out the $k-1$ non-boss board positions from the remaining $n-1$ employees in $\binom{n-1}{k-1}$ ways, giving the right-hand side.</p>

<p>A similar argument works for the multiset coefficient. We can place $k$ flags on $n$ poles, then pick one of them top be the “boss-flag”. Alternatively, we can pick one of $n$ poles to put the boss-flag on. We then need $k-1$ more flags to be put in $n + 1$ locations: the $n-1$ empty poles, above the boss-flag, or below the boss-flag. The new identity is, then:</p>

\[k{\bigg(\kern-0.4em\dbinom{n}{k}\kern-0.4em\bigg)} = n {\bigg(\kern-0.4em\dbinom{n+1}{k-1}\kern-0.4em\bigg)} .\]

<h3 id="5-many-bosses">5. Many bosses</h3>

<p>Suppose the board has not merely one boss but a sub-board of $j$ bosses. Again, we can pick $k$ board-members then promote $j$ of them, or we can pick $j$ bosses then the $k-j$ remaining non-bosses. We get</p>

\[\binom{k}{j} \binom{n}{k} = \binom{n}{j}\binom{n-j}{k-j} .\]

<p>The multiset version of this is also similar. We can put up $k$ flags on $n$ poles, then pick $j$ of them to be boss-flags. In this second step, we can only pick each hoisted flag at most once to be a boss-flag, so that gives a binomial, not multiset, coefficient on the left-hand side. As before, if we pick the $j$ boss-flags first, this creates $n+j$ spaces for the remaining flags, since each boss flag divides a location in two. We get:</p>

\[\binom{k}{j} {\bigg(\kern-0.4em\dbinom{n}{k}\kern-0.4em\bigg)} = {\bigg(\kern-0.4em\dbinom{n}{j}\kern-0.4em\bigg)} {\bigg(\kern-0.4em\dbinom{n+j}{k-j}\kern-0.4em\bigg)} .\]

<p>I’m not sure whether I should be fully satisfied with this one or not: it feels a bit of a compromise for one of the coefficients in this expression to be a rogue binomial coefficient, rather than all four terms being multiset coefficients. But I can’t think of anything better – can you? (Alternatively, is there an “opposite” identity with three binomial coefficients and one multiset coefficient?)</p>

<h3 id="6-generating-function">6. Generating function</h3>

<p>The generating function of the binomial coefficients is</p>

\[\sum_{k=0}^n \binom{n}{k} x^k = (1 + x)^n .\]

<p>The generating function of the multiset coefficients is</p>

\[\sum_{k=0}^\infty {\bigg(\kern-0.4em\dbinom{n}{k}\kern-0.4em\bigg)} x^k = (1 - x)^{-n} .\]

<p>To see the first of these, imagine multiplying out the brackets of</p>

\[(1+x)^n = (1+x)(1+x)\cdots(1+x) .\]

<p>To get a term $x^k$, you need to have picked an “$x$” from $k$ of the sets of brackets and 1s from the other $n-k$ sets of brackets. This can be done in $\binom{n}{k}$ ways.</p>

<p>For the second, we use the geometric progression formula</p>

\[(1-x)^{-1} = (1 + x + x^2 + x^3 + \cdots)\]

<p>and imagine multiplying out</p>

\[(1-x)^{-n} = (1 + x + x^2 + \cdots)\cdots (1 + x + x^2 + \cdots) .\]

<p>To get a term $x^k$, you need to have picked an “$x$” $k$ times, but that could be multiple $x$’s from the same bracket by picking an $x^2$ or $x^3$ and so on. So we are choosing with multiplicities, giving $\big(\kern-0.2em\tbinom{n}{k}\kern-0.2em\big)$ ways.</p>

<h3 id="7-maximum-item">7. Maximum item</h3>

<p>Another binomial coefficient identity is this:</p>

\[\sum_{m=1}^n \binom{m-1}{k-1} = \binom{n}{k} ,\]

<p>known as the <a href="https://en.wikipedia.org/wiki/Hockey-stick_identity">“hockeystick identity”</a>, due to the shape the relevant coefficients draw on Pascal’s triangle. (Some people prefer to write the lower limit in the sum as $m = k$, since the summands for $m = 1, 2, \dots, k - 1$ are all 0.)</p>

<p>This identity comes from counting the $k$-subsets of ${1, 2, \dots, n}$ based on their maximum item. If the maximum item is $m$, then you need to choose the remaining $k - 1$ items from the $m-1$ items that are smaller than $m$.</p>

<p>For multisets, the argument is almost the same, but you can pick more “joint-maximum” items that are equal to $m$ if you want. So you need to choose the remaining $k-1$ items from the $m$ items that are smaller than <em>or equal to</em> $m$. Hence we get</p>

\[\sum_{m=1}^n \bigg(\kern-0.4em\dbinom{m}{k-1}\kern-0.4em\bigg) = \bigg(\kern-0.4em\dbinom{n}{k}\kern-0.4em\bigg)\]

<p>(where all the summands are nonzero).</p>

<h3 id="9-men-and-women">9. Men and women</h3>

<p>Vandermonde’s identity is the result</p>

\[\binom{n+m}{k} = \sum_{j=0}^k \binom{n}{j} \binom{m}{k-j} .\]

<p>Suppose the office has $n+m$ employees: $n$ women and $m$ men. Again, we want to choose a board of $k$ employees, which can be done in $\binom{n+m}{k}$ ways. We can also count the boards by their gender split: the all male boards, those with 1 woman and $k-1$ men, and so on. The number of ways to pick a board with $j$ women and the remaining $k-j$ members being men is the product $\binom{n}{j} \binom{m}{k-j}$.</p>

<p>Exactly the same argument works for multisets, so we have the same result:</p>

\[\bigg(\kern-0.4em\dbinom{n+m}{k}\kern-0.4em\bigg) = \sum_{j=0}^k \bigg(\kern-0.4em\dbinom{n}{j}\kern-0.4em\bigg) \bigg(\kern-0.4em\dbinom{m}{k-j}\kern-0.4em\bigg) .\]

<h3 id="10-symmetry">10. Symmetry</h3>

<p>I’ve left an important binomial identity – maybe the most important one – until last: the symmetry relation</p>

\[\binom{n}{k} = \binom{n}{n-k} .\]

<p>You can choose a set of $k$ items from $n$ items; but, alternatively, you can choose the $n-k$ items that are <em>not</em> going to be in your set, leaving the $k$ items you want left over.</p>

<p>I left this until last, because I wasn’t sure what the right multiset version of this is. The following is certainly <em>a</em> symmetry relation, at least. Recall the stars-and-bars construction from before: we had</p>

<ul>
  <li>$n-1$ bars, which define $n$ boxes,</li>
  <li>$k$ stars, representing $k$ objects.</li>
</ul>

<p>What if we now swap the roles of the stars and the bars – so now the stars are defining the boxes, into which we places some bars representing objects? We would then have</p>

<ul>
  <li>$k$ stars, which define $k+1$ boxes,</li>
  <li>$n-1$ bars, representing $n-1$ objects.</li>
</ul>

<p>Since these are both counting the same patterns of stars and bars, we get</p>

\[\bigg(\kern-0.4em\dbinom{n}{k}\kern-0.4em\bigg) = \bigg(\kern-0.4em\dbinom{k+1}{n-1}\kern-0.4em\bigg) .\]

<p>(This argument sets up an explicit bijection between $k$-submultisets of an $n$-set and $(n-1)$-submultisets of a $(k+1)$-set. I admit I’d never thought about this bijection before. I’d like to know more about its properties.)</p>

<p>It’s not totally clear this is the right multiset generalisation of the binomial coefficient symmetry relation – in particular, the swapping over of top and bottom (the $k$ now appears on the top of the multiset coefficient on the right-hand side of the equation) seems a bit weird. But I think it does work: if you do <em>the forbidden thing I’ve told you not to do</em> and convert the multiset coefficient to a binomial coefficient, apply the symmetry relation, then convert back, you get</p>

\[\bigg(\kern-0.4em\dbinom{n}{k}\kern-0.4em\bigg) = \binom{n+k-1}{k} = \binom{n+k-1}{n-1} = \binom{(k+1) + (n-1) - 1}{n-1} = \bigg(\kern-0.4em\dbinom{k+1}{n-1}\kern-0.4em\bigg) ,\]

<p>which is what we claimed, although don’t tell anyone I did this.</p>

<h2 id="in-summary">In summary</h2>

<p>So to gather everything together, here are the results we’ve discussed:</p>

<table>
  <thead>
    <tr>
      <th style="text-align: center">Binomial coefficient</th>
      <th style="text-align: center">Multiset coefficient</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td style="text-align: center">\(\dbinom{n}{k} = \dfrac{n^{\underline{k}}}{k!}\)</td>
      <td style="text-align: center">\(\bigg(\kern-0.4em\dbinom{n}{k}\kern-0.4em\bigg) = \dfrac{n^{\overline{k}}}{k!}\)</td>
    </tr>
    <tr>
      <td style="text-align: center">\(\dbinom{n}{k} = \dbinom{n}{n-k}\)</td>
      <td style="text-align: center">\(\bigg(\kern-0.4em\dbinom{n}{k}\kern-0.4em\bigg) = \bigg(\kern-0.4em\dbinom{k+1}{n-1}\kern-0.4em\bigg)\)</td>
    </tr>
    <tr>
      <td style="text-align: center">\(\dbinom{n}{k} = \dbinom{n-1}{k} + \dbinom{n-1}{k-1}\)</td>
      <td style="text-align: center">\(\bigg(\kern-0.4em\dbinom{n}{k}\kern-0.4em\bigg) = \bigg(\kern-0.4em\dbinom{n-1}{k}\kern-0.4em\bigg) + \bigg(\kern-0.4em\dbinom{n}{k-1}\kern-0.4em\bigg)\)</td>
    </tr>
    <tr>
      <td style="text-align: center">\(k\dbinom{n}{k} = n \dbinom{n-1}{k-1}\)</td>
      <td style="text-align: center">\(k\bigg(\kern-0.4em\dbinom{n}{k}\kern-0.4em\bigg) = n \bigg(\kern-0.4em\dbinom{n+1}{k-1}\kern-0.4em\bigg)\)</td>
    </tr>
    <tr>
      <td style="text-align: center">\(\dbinom{k}{j} \dbinom{n}{k} = \dbinom{n}{j}\dbinom{n-j}{k-j}\)</td>
      <td style="text-align: center">\(\dbinom{k}{j} \bigg(\kern-0.4em\dbinom{n}{k}\kern-0.4em\bigg) = \bigg(\kern-0.4em\dbinom{n}{j}\kern-0.4em\bigg) \bigg(\kern-0.4em\dbinom{n+j}{k-j}\kern-0.4em\bigg)\)</td>
    </tr>
    <tr>
      <td style="text-align: center">\(\displaystyle\sum_{k=0}^n \binom{n}{k} x^k = (1 + x)^n\)</td>
      <td style="text-align: center">\(\displaystyle\sum_{k=0}^\infty \bigg(\kern-0.4em\dbinom{n}{k}\kern-0.4em\bigg) x^k = (1 - x)^{-n}\)</td>
    </tr>
    <tr>
      <td style="text-align: center">\(\displaystyle\sum_{m=1}^n \binom{m-1}{k-1} = \dbinom{n}{k}\)</td>
      <td style="text-align: center">\(\displaystyle\sum_{m=1}^n \bigg(\kern-0.4em\dbinom{m}{k-1}\kern-0.4em\bigg) = \bigg(\kern-0.4em\dbinom{n}{k}\kern-0.4em\bigg)\)</td>
    </tr>
    <tr>
      <td style="text-align: center">\(\dbinom{n+m}{k} = \displaystyle\sum_{j=0}^k \dbinom{n}{j} \dbinom{m}{k-j}\)</td>
      <td style="text-align: center">\(\bigg(\kern-0.4em\dbinom{n+m}{k}\kern-0.4em\bigg) = \displaystyle\sum_{j=0}^k \bigg(\kern-0.4em\dbinom{n}{j}\kern-0.4em\bigg) \bigg(\kern-0.4em\dbinom{m}{k-j}\kern-0.4em\bigg)\)</td>
    </tr>
  </tbody>
</table>

<p>And remember: the second column is no less important than the first column! Justice for the multiset coefficient!</p>]]></content><author><name></name></author><category term="maths" /><summary type="html"><![CDATA[Being the second in a series of blogposts quite unnecessarily scolding the reader about the binomial coefficient (Previously: “Don’t write the binomial coefficient as n! / k! (n-k)!”)]]></summary></entry><entry><title type="html">4 is discrete π</title><link href="https://mpaldridge.github.io/blog/4pi.html" rel="alternate" type="text/html" title="4 is discrete π" /><published>2026-02-01T00:00:00+00:00</published><updated>2026-02-01T00:00:00+00:00</updated><id>https://mpaldridge.github.io/blog/4-discrete-pi</id><content type="html" xml:base="https://mpaldridge.github.io/blog/4pi.html"><![CDATA[<h2 id="recap">Recap</h2>

<p><a href="2e.html">In my last blogpost</a>, I looked for a discrete version of the exponential function</p>

\[\exp(x) = \frac{x^0}{0!} + \frac{x^1}{1!} + \frac{x^2}{2!} + \frac{x^3}{3!} + \cdots .\]

<p>By swapping the standard power $x^n$ for the falling factorial power $x^\underline{n} = x(x-1)\cdots(x-n+1)$, we got the “discrete exponential”</p>

\[\begin{align} \operatorname{dexp}(x) &amp;= \frac{x^\underline{0}}{0!} + \frac{x^\underline{1}}{1!} + \frac{x^\underline{2}}{2!} + \frac{x^\underline{3}}{3!} + \cdots \\
&amp;= \binom x0 + \binom x1 + \binom x2 + \binom x3 + \cdots , \end{align}\]

<p>which is just $\operatorname{dexp}(x) = 2^x$.</p>

<p>Pleasingly, just as $\frac{\mathrm{d}}{\mathrm dx} \exp(x) = \exp(x)$, so we have a “discrete equivalent result” $\Delta \operatorname{dexp}(x) = \operatorname{dexp}(x)$, where $\Delta$ is the discrete difference $\Delta f(x) = f(x+1)-f(x)$.</p>

<p>We also found that, more generally, the discrete equivalent of $\exp(\alpha x)$ (considered as a function of $x$) is $(1+\alpha)^x$.</p>

<h2 id="discrete-cos-and-sin-non-negative-integer-x">Discrete cos and sin (non-negative integer <em>x</em>)</h2>

<p>So, for the next step, how about discrete sine and discrete cosine? Can we define discrete versions of sin and cos that end up having similar properties to their standard trigonometric counterparts?</p>

<p>The standard Taylor series definitions are</p>

\[\begin{align} \cos(x) &amp;= \frac{x^0}{0!} - \frac{x^2}{2!} + \frac{x^4}{4!} - \cdots \\
                 \sin(x) &amp;= \frac{x^1}{1!} - \frac{x^3}{3!} + \frac{x^5}{5!} - \cdots \end{align}\]

<p>By our now-standard procedure of swapping powers for falling factorials then recognising $x^\underline{n}/n!$ as a binomial coefficient, we should take the following definitions:</p>

\[\begin{align} \operatorname{dcos}(x) &amp;= \binom x0 - \binom x2 + \binom x4 - \cdots \\
                 \operatorname{dsin}(x) &amp;= \binom x1 - \binom x3 + \binom x5 - \cdots \end{align}\]

<p>For the moment, let’s stick to non-negative integer $x = 0, 1, 2, \dots$. The discrete cos sequence is <a href="https://oeis.org/A146559">A146559</a></p>

\[1, 1, 0, -2, -4, -4, 0, 8, 16, 16, 0, -32, -64, -64, 0, 128, 256, 256, \dots\]

<p>and the discrete sin sequence is <a href="https://oeis.org/A009545">A009545</a></p>

\[0, 1, 2, 2, 0, -4, -8, -8, 0, 16, 32, 32, 0, -64, -128, -128, 0, 256, \dots\]

<p>Pleasingly, we can see the sequences are related by the difference operator:</p>

\[\begin{align}
\Delta \operatorname{dcos}(x) &amp;= - \operatorname{dsin}(x) \\
\Delta \operatorname{dsin}(x) &amp;= \operatorname{dcos}(x) ;
\end{align}\]

<p>which is exactly the same structure as the derivatives of usual sin and cos:</p>

\[\begin{align}
\frac{\mathrm{d}}{\mathrm{d}x} \operatorname{cos}(x) &amp;= - \operatorname{sin}(x) \\
\frac{\mathrm{d}}{\mathrm{d}x}\operatorname{sin}(x) &amp;= \operatorname{cos}(x) .
\end{align}\]

<p>Further, just by looking at the two sequences, we can tell that we have sort-of-periodic behaviour modulo 8.</p>

<table>
  <thead>
    <tr>
      <th style="text-align: center"><em>x</em></th>
      <th style="text-align: center">dcos</th>
      <th style="text-align: center">dsin</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td style="text-align: center">$x = 0 \bmod 8$</td>
      <td style="text-align: center">$\operatorname{dcos}(x) = 2^{x/2}$</td>
      <td style="text-align: center">$\operatorname{dsin}(x) = 0$</td>
    </tr>
    <tr>
      <td style="text-align: center">$x = 1 \bmod 8$</td>
      <td style="text-align: center">$\operatorname{dcos}(x) = 2^{(x-1)/2}$</td>
      <td style="text-align: center">$\operatorname{dsin}(x) = 2^{(x-1)/2}$</td>
    </tr>
    <tr>
      <td style="text-align: center">$x = 2 \bmod 8$</td>
      <td style="text-align: center">$\operatorname{dcos}(x) = 0$</td>
      <td style="text-align: center">$\operatorname{dsin}(x) = 2^{x/2}$</td>
    </tr>
    <tr>
      <td style="text-align: center">$x = 3 \bmod 8$</td>
      <td style="text-align: center">$\operatorname{dcos}(x) = -2^{(x-1)/2}$</td>
      <td style="text-align: center">$\operatorname{dsin}(x) = 2^{(x-1)/2}$</td>
    </tr>
    <tr>
      <td style="text-align: center">$x = 4 \bmod 8$</td>
      <td style="text-align: center">$\operatorname{dcos}(x) = -2^{x/2}$</td>
      <td style="text-align: center">$\operatorname{dsin}(x) = 0$</td>
    </tr>
    <tr>
      <td style="text-align: center">$x = 5 \bmod 8$</td>
      <td style="text-align: center">$\operatorname{dcos}(x) = -2^{(x-1)/2}$</td>
      <td style="text-align: center">$\operatorname{dsin}(x) = -2^{(x-1)/2}$</td>
    </tr>
    <tr>
      <td style="text-align: center">$x = 6 \bmod 8$</td>
      <td style="text-align: center">$\operatorname{dcos}(x) = 0$</td>
      <td style="text-align: center">$\operatorname{dsin}(x) = -2^{x/2}$</td>
    </tr>
    <tr>
      <td style="text-align: center">$x = 7 \bmod 8$</td>
      <td style="text-align: center">$\operatorname{dcos}(x) = 2^{x/2}$</td>
      <td style="text-align: center">$\operatorname{dsin}(x) = -2^{(x-1)/2}$</td>
    </tr>
  </tbody>
</table>

<p>These look very reminiscent of how the usual cos and sin behave: we have periodic zeros, with the functions alternately positive and negative in the intervals between those zeros. More specifically, we have for the usual trigonometric functions:</p>

<ul>
  <li>sin has zeros at $0, \pi, 2\pi, 3\pi, \dots$</li>
  <li>cos has zeros at $\frac{\pi}{2}, \frac{3\pi}{2}, \frac{5\pi}{2}, \dots$</li>
  <li>cos and sin both have period $2\pi$</li>
</ul>

<p>and for our discrete equivalents:</p>

<ul>
  <li>dsin has zeros at $0, 4, 8, 12, \dots, = 0, 4, 2\times 4, 3 \times 4, \dots$</li>
  <li>dcos has zeros at $2, 6, 10, \dots = \frac{4}{2}, \frac{3 \times 4}{2}, \frac{5 \times 4}{2}, \dots$</li>
  <li>dcos and dsin both have sort-of-periodic behaviour with “period” $8 = 2\times 4$</li>
</ul>

<p>It seems clear from these that for our new discrete trigonometric operations, 4 is playing the role that $\pi$ plays for the normal trigonometric operations: whence this blogpost’s title.</p>

<p>On the other hand, the usual sin and cos are bounded between -1 and +1, which is not true of the discrete sin and cos, which seem to growing over time (between the periodic zeros). For example, the standard sin and cos have</p>

<ul>
  <li>$\cos(x)^2 + \sin(x)^2 = 1$</li>
  <li>$\sin(x) = \cos\big(x - \frac{\pi}{2}\big)$</li>
</ul>

<p>while the discrete sin and cos have</p>

<ul>
  <li>$\operatorname{dcos}(x)^2 + \operatorname{dsin}(x)^2 = 2^x$</li>
  <li>$\operatorname{dsin}(x) = 2\operatorname{dcos}(x - 2)$</li>
</ul>

<p>In fact, if we really wanted to coerce the discrete sin and cos into the usual versions, we could do so: it is the case that</p>

\[\begin{align} \operatorname{dcos}(x) &amp;= 2^{x/2} \cos \left(\frac{\pi x}{4} \right) \\
\operatorname{dsin}(x) &amp;= 2^{x/2} \sin \left(\frac{\pi x}{4} \right) , \end{align}\]

<p>at least for non-negative integer $x$, thanks to the convenient expression $\sin (\frac{\pi}{4}) = \cos (\frac{\pi}{4}) = 1/\sqrt{2}$. Can I prove these formulas for dcos in terms of cos and dsin in terms of sin? Might they even be true for non-integer $x$?</p>

<h2 id="discrete-cos-and-sin-general-x">Discrete cos and sin (general <em>x</em>)</h2>

<p>As is probably clear from the disorganised nature of this post, I’m writing as I work things out. And, at this point, it’s just occurred to me that I may have been going about things the wrong way.</p>

<p>I had started with the Taylor series definitions of cos and sin. But maybe I should have started with these definitions instead:</p>

\[\begin{align}
      \cos(x) &amp;= \frac{\mathrm{e}^{\mathrm{i}x} + \mathrm{e}^{-\mathrm{i}x}}{2} \\
      \sin(x) &amp;= \frac{\mathrm{e}^{\mathrm{i}x} - \mathrm{e}^{-\mathrm{i}x}}{2\mathrm{i}} .
\end{align}\]

<p>I argued last time that the discrete equivalent of $\mathrm{e}^{\alpha x}$ is $(1 + \alpha)^x$, so this suggests we should take the definitions</p>

\[\begin{align}
      \operatorname{dcos}(x) &amp;= \frac{(1+\mathrm{i})^x + (1-\mathrm{i})^x}{2} \\
      \operatorname{dsin}(x) &amp;= \frac{(1+\mathrm{i})^x - (1-\mathrm{i})^x}{2\mathrm{i}} .
\end{align}\]

<p>Are these the same as the binomial coefficient definitions from before? Yes they are: use the binomial theorem</p>

\[\begin{align} (1 + i)^x &amp;= \sum_{n=0}^\infty \binom{x}{n} \mathrm{i}^n \\
  (1 - i)^x &amp;= \sum_{n=0}^\infty \binom{x}{n} (-\mathrm{i})^n , \end{align}\]

<p>and check where you get constructive or destructive interference in the sums.</p>

<p>This generalises much more easily to real values of $x$. And, more importantly, allows me easily to draw some pictures. Below, discrete cos is in blue and discrete sin in red; the points are the integer values.</p>

<p><img src="../assets/img/dcos.png" alt="" /></p>

<p>Is it true that for all real $x$ we have</p>

\[\begin{align} \operatorname{dcos}(x) &amp;= 2^{x/2} \cos \left(\frac{\pi x}{4} \right) \\
\operatorname{dsin}(x) &amp;= 2^{x/2} \sin \left(\frac{\pi x}{4} \right) , \end{align} ,\]

<p>as I suggested earlier? Yes it is. To see this, we want to put our complex numbers into modulus–argument form: that is, $1 + i = \sqrt{2} \mathrm{e}^{\mathrm i \pi/4}$ and $1 + i = \sqrt{2} \mathrm{e}^{-\mathrm i \pi/4}$. Then we have</p>

\[\operatorname{dcos}(x) = \frac{\big(\sqrt{2} \mathrm{e}^{\mathrm i \pi/4}\big)^x + \big(\sqrt{2} \mathrm{e}^{\mathrm i \pi/4}\big)^x}{2} = (\sqrt{2})^x \, \frac{\mathrm{e}^{\mathrm i \pi x/4} + \mathrm{e}^{\mathrm i \pi x/4}}{2}  = 2^{x/2} \cos \left(\frac{\pi x}{4} \right) ,\]

<p>and similarly for dsin. This proves the result.</p>]]></content><author><name></name></author><category term="maths" /><summary type="html"><![CDATA[Recap]]></summary></entry><entry><title type="html">2 is discrete e</title><link href="https://mpaldridge.github.io/blog/2e.html" rel="alternate" type="text/html" title="2 is discrete e" /><published>2026-01-29T00:00:00+00:00</published><updated>2026-01-29T00:00:00+00:00</updated><id>https://mpaldridge.github.io/blog/2-discrete-e</id><content type="html" xml:base="https://mpaldridge.github.io/blog/2e.html"><![CDATA[<p>Here’s a question that came into my mind as I was falling asleep last night: What’s the discrete equivalent of the exponential function $\exp(x) = \mathrm{e}^x$?</p>

<p>What did my brain mean by this question? Maybe something like this: If you take a definition of the exponential, what is the most plausible (or <em>a</em> plausible) generalisation of that where more naturally continuous operations are replaced by more naturally discrete ones? This is not, of course, a formally precisely stated question, but seemed intriguing enough to think about for as long as I remained awake.</p>

<p>Two definitions of the exponential I thought of were these. First, the exponential is the solution to the differential equation $f’(x) = f(x)$. Second, the exponential is defined by the Taylor series</p>

\[\exp(x) = \sum_{n=0}^\infty \frac{x^n}{n!} .\]

<p>Let’s start with the first, the differential equation definition. The derivative $f’$ is a “naturally continuous” operation; a more natural discrete equivalent is the discrete difference $\Delta f(x) = f(x+1)-f(x)$. So if the “continuous exponential” satisfies $f’(x) = f(x)$, perhaps the “discrete exponential” should satisfy $\Delta f(x) = f(x)$. A few moments thought should be enough to convince you that the solution is $f(x) = 2^x$, since</p>

\[2^{x+1} - 2^x = 2^x(2 - 1) = 2^x .\]

<p>What about the second, the Taylor series equation definition. I would argue that to get a discrete equivalent it makes sense to replace the power $x^n$ by the falling factorial power $x^{\underline{n}} = x(x-1)\cdots(x-n+1)$ – this came up in <a href="sums-powers-1.html">my discussion of sums of powers a while ago</a>. In that case we get</p>

\[f(x) = \sum_{n=0}^\infty \frac{x^{\underline{n}}}{n!} = \sum_{n=0}^\infty \binom{x}{n} ,\]

<p>which has become a sum of binomial coefficients. For integer $x$, this is the total number of subsets from a collection of $x$ items, summed over the subsets of size $n = 0, 1, 2, \dots$. This total number of subsets is $2^x$ (each item can be either included in the subset or not), giving $f(x) = 2^x$ again. (This also true non-integer $x$, by the binomial theorem.)</p>

<p>So the two different definitions have both suggested to us that $2^x$ is the discrete equivalent of $\mathrm{e}^x$: or that “2 is discrete e”, as I put it (slightly facetiously) in the title of this blogpost.</p>

<p>More generally, we could look at a discrete equivalent of $\mathrm{e}^{\alpha x} = \exp(\alpha x)$, thinking of $\alpha$ as a fixed constant and $x$ as the argument of the function. This satisfies the differential equation $f’(x) = \alpha f(x)$; moving to the discrete equivalent $\Delta f(x) = \alpha f(x)$ gives $f(x) = (1 + \alpha)^x$, since</p>

\[(1+\alpha)^{x+1} - (1+\alpha)^x = (1+\alpha)^x(1 + \alpha - 1) = \alpha(1+\alpha)^x .\]

<p>Similarly, the Taylor series approach suggests</p>

\[f(x) = \sum_{n=0}^\infty \frac{\alpha^n x^{\underline{n}}}{n!} = \sum_{n=0}^\infty \binom{x}{n} \alpha^n = (1+\alpha)^x ,\]

<p>too. (Since $\alpha$ is the constant, I don’t think it needs to be “discretised” from the power $\alpha^n$ to any falling factorial.) Both ways, we get the same equivalent $(1 + \alpha)^x$; of course, setting $\alpha = 1$ gets back $2^x$, as before.</p>

<h2 id="two-appendices">Two appendices</h2>

<p>I mentioned this to <a href="https://gracar.org/">Pete</a> and <a href="https://eps.leeds.ac.uk/faculty-engineering-physical-sciences/staff/13180/dr-ben-lees">Ben</a> at lunchtime, and they thought of two interesting extra directions to take this.</p>

<p>Pete asked what if we look for a discrete equivalent not on the integers but on a mesh of width $h$. That would suggest using the discrete difference</p>

\[\Delta_h f(x) = \frac{f(x + h) - f(x)}{h}\]

<p>instead. It’s easy to check that $\Delta_h f(x) = f(x)$ gives $(1 + h)^{x/h}$, since</p>

\[\frac{(1 + h)^{(x+h)/h} + (1 + h)^{x/h}}{h} = \frac{(1 + h)^{x/h}\big((1+h)^{1} - 1\big)}{h} = \frac{h}{h}(1 + h)^{x/h} = (1 + h)^{x/h} .\]

<p>Note that setting $h = 1$ gets back $(1 + 1)^{x/1} = 2^x$, while sending $h \to 0$ gives the limiting value</p>

\[(1 + h)^{x/h} = \big( (1 + h)^{1/h} \big)^x \to \mathrm{e}^x ,\]

<p>the continuous exponential. The same argument suggests the width-$h$ discrete equivalent of $\mathrm{e}^{\alpha x}$ is $(1+\alpha h)^{x/h}$.</p>

<p>Ben pointed out there’s a “mirror image” way to discretise things: instead of the discrete forward difference $\Delta f(x) = f(x+1) - f(x)$ you use the discrete backward difference $\nabla f(x) = f(x) - f(x-1)$ and instead of the falling factorial $x^{\underline n} = x(x-1) \cdots (x-n+1)$ you use the rising factorial $x^{\overline n} = x(x+1) \cdots (x+n-1)$.</p>

<p>The backward difference equation $\nabla f(x) = \alpha f(x)$ has solution $f(x) = (1 - \alpha)^{-x}$, since</p>

\[(1 - \alpha)^{-x} - (1-\alpha)^{-(x-1)} = (1-\alpha)^{-x}\big(1 - (1 - \alpha)\big) = \alpha (1-\alpha)^{-x} .\]

<p>Similarly, the Taylor series gives</p>

\[f(x) = \sum_{n=0}^\infty \frac{\alpha^n x^{\overline{n}}}{n!} = \sum_{n=0}^\infty \binom{x+n-1}{n} \alpha^n = (1-\alpha)^{-x} ,\]

<p>by a moderately famous result I’m not going to prove here. Either way, we get $(1 - \alpha)^{-x}$ the mirror-image way, compared to $(1 + \alpha)^x$ the usual way. But here, you can’t set $\alpha = 1$ to get back “discrete e”, because at $\alpha = 1$ you get $0^{-x} = (1/0)^x$, and division by 0 isn’t allowed.</p>]]></content><author><name></name></author><category term="maths" /><summary type="html"><![CDATA[Here’s a question that came into my mind as I was falling asleep last night: What’s the discrete equivalent of the exponential function $\exp(x) = \mathrm{e}^x$?]]></summary></entry><entry><title type="html">Don’t write the binomial coefficient as n! / k! (n-k)!</title><link href="https://mpaldridge.github.io/blog/binomial.html" rel="alternate" type="text/html" title="Don’t write the binomial coefficient as n! / k! (n-k)!" /><published>2025-11-21T00:00:00+00:00</published><updated>2025-11-21T00:00:00+00:00</updated><id>https://mpaldridge.github.io/blog/binomial</id><content type="html" xml:base="https://mpaldridge.github.io/blog/binomial.html"><![CDATA[<p>The binomial coefficient $\binom{n}{k}$, pronounced “$n$ choose $k$”, is the number of ways of choosing a collection of $k$ objects from a set of $n$ objects.</p>

<p>To calculate the binomial coefficient, it’s best to start by thinking about picking the $k$ objects in order. There are $n$ choices for the first object, then $n-1$ choices for the second object (since you can’t pick the one you just picked again), $n-2$ for the third, and so on, down to $n-k+1$ for the final object (avoiding the $k-1$ you’ve already picked). So to pick the objects in order, there are</p>

\[n^{\underline{k}} = n \times (n-1) \times \cdots \times (n-k+1)\]

<p>ways to do it. This number $n^{\underline{k}}$ is called the <em>falling factorial</em> (said “$n$ to the $k$ falling”) or <em>permutation number</em>. But we wanted the objects chosen where the order <em>doesn’t</em> matter. So we’ve over-counted. Every potential collection has been counted</p>

\[k! = k \times (k-1) \times \cdots \times 2 \times 1\]

<p>(“$k$ factorial”) times. So we have to divide through by that, to get</p>

\[\binom{n}{k} = \frac{n^{\underline{k}}}{k!} .\]

<p>This is a nice formula for calculating the binomial coefficient. Let’s call it <strong>Formula A</strong>.</p>

<p>(There are other notations used for the falling factorial, such as $(n)_k$ or $P(n,k)$. I personally like $n^{\underline{k}}$, which I think is due to Donald Knuth, but I’m fine with any of the others.)</p>

<p>But if you look it up the binomial coefficient in books or on the web, you’re much more likely to find the formula</p>

\[\binom{n}{k} = \frac{n!}{k!\,(n-k)!} .\]

<p>This formula, let’s call it <strong>Formula B</strong>, is also correct, in that is mathematically equal to Formula A for $k = 0, 1, \dots, n$. It’s also much, much more popular than Formula A. But I think it’s bad!</p>

<h3 id="1-difficult-to-understand">1. Difficult to understand</h3>

<p>The first thing is that it’s not so easy to interpret how Formula B corresponds to “the number of ways to choose $k$ objects from a set of $n$ objects.”</p>

<p>For Formula A, the numerator $n^\underline{k}$ is the number of ordered ways to pick the objects and the denominator $k!$ is the number of orderings for each collection. Easy.</p>

<p>For Formula B, the numerator $n!$ is the number of ways of ordering the whole set. So imagine ordering the entire set then picking the first $k$ items out of that ordering. The two terms in the denominator are $k!$ and $(n-k)!$ are because we don’t care about either the order within the first $k$ items (because order of our chosen items doesn’t matter) or the order within the last $n-k$ items (because we’re not picking them anyway). But this is weird: why are we bothering to order the whole set when we’re only going to pick a few of the items?</p>

<p>Alternatively, Formula B-ers might argue that $n! / (n-k)!$ is just another way of writing $n^{\underline{k}}$. I suppose in a way it is: we have</p>

\[\frac{n!}{(n-k)!} = \frac{n \times (n-1) \times \cdots \times (n-k+1) \times (n-k) \times (n-k-1) \times \cdots \times 1}{\phantom{n \times (n-1) \times \cdots \times (n-k+1) \times {}} (n-k) \times (n-k-1) \times \cdots \times 1} ,\]

<p>which ensures the right-hand tail of the top factorial cancels. But I dislike this – it’s the sort of clever-clever writing of of an expression in terms of other things that, yes, avoids defining notation for the falling factorial, but goes out of its way to disguise what’s actually going on. Reject such too-smart-by-half rewritings of easily interpretable expressions!</p>

<h3 id="2-doesnt-work-outside-the-range">2. Doesn’t work outside the range</h3>

<p>How many ways are there of choosing 7 items from a set of 5 items? Zero! It’s obviously impossible to pick 7 items out of 5, because once you’ve picked 5 items you’ve run out and have none left. What do the formulas have to say about this?</p>

<p>Formula A says</p>

\[\binom{5}{7} = \frac{5^{\underline{7}}}{5!} = \frac{0}{120} = 0 ,\]

<p>since the numerator is</p>

\[5^{\underline{7}} = 5 \times 4 \times 3 \times 2 \times 1 \times 0 \times (-1) = 0\]

<p>due to having a 0 in it. So Formula A gives the correct answer of 0.</p>

<p>What about Formula B? Here we have</p>

\[\binom{5}{7} = \frac{5!}{7!\,(-2)!} = \frac{120}{5040 \times ???} ,\]

<p>since there’s no such thing as “minus 2 factorial”. So Formula B fails. (You can’t get around this using the <a href="https://en.wikipedia.org/wiki/Gamma_function">Gamma function</a>; that’s still undefined for negative integers.)</p>

<h3 id="3-silly-with-big-numbers">3. Silly with big numbers</h3>

<p>Suppose I want to know how many ways I can choose 2 items from a set of 25. So I want to know the binomial coefficient $\binom{25}{2}$.</p>

<p>With Formula A, this is</p>

\[\binom{25}{2} = \frac{25^{\underline{2}}}{2!} = \frac{600}{2} = 300 .\]

<p>Nice and simple – you can even do the calculation in your head.</p>

<p>But with Formula B, this is</p>

\[\binom{25}{2} = \frac{25!}{2! \times 23!} = \frac{15\,511\,210\,043\,330\,985\,984\,000\,000}{2 \times 25\,852\,016\,738\,884\,976\,640\,000} ,\]

<p>which apparently also comes out as 300 (although I certainly can’t do it in my head).</p>

<p>So, first: just look at it – that is obviously very silly! More seriously, this shows that Formula B will have numerical stability problems for large numbers: when $n$ gets large, your computer will have to round the gigantic number $n!$, and this can lead to inaccuracy in calculating $\binom{n}{k}$.</p>

<h3 id="4-doesnt-work-with-non-integer-n">4. Doesn’t work with non-integer <em>n</em></h3>

<p>The binomial coefficient is also useful when “multiplying out of brackets”. Here, we have</p>

\[(a + b)^n = \sum_{k=0}^n \binom{n}{k} a^k b^{n-k}\]

<p>But we might also want to think about $(a + b)^x$ where $x$ is not an integer. In that case the formula</p>

\[(a + b)^x = \sum_{k=0}^\infty \binom{x}{k} a^k b^{x-k}\]

<p>still holds for $\vert a\vert &lt; \vert b\vert$, where here the binomial coefficient means the same thing as in Formula A:</p>

\[\binom{x}{k} = \frac{x^{\underline{k}}}{k!} = \frac{x(x-1)\cdots(x-k+1)}{k!} .\]

<p>So, for example, with $b = 1$, $\vert a\vert &lt; 1$, and $x = 1/2$, we have the correct formula</p>

\[\begin{align}
(a + 1)^{1/2} &amp;= \binom{1/2}{0} + \binom{1/2}{1} a + \binom{1/2}{2} a^2 + \binom{1/2}{3} a^3 + \cdots \\
  &amp;= 1 + \frac12 a - \frac{1}{8} a^2 + \frac{1}{16} a^3 + \cdots ,
\end{align}\]

<p>where we have used Formula A to get, for example</p>

\[\binom{1/2}{3} = \frac{(\frac12)^{\underline{3}}}{3!} = \frac{\frac12 \times (-\frac12) \times (-\frac32) }{6} = \frac{\frac38}{6} = \frac{1}{16} ,\]

<p>working perfectly well when the top of the binomial coefficient isn’t an integer.</p>

<p>What happens with Formula B? We get</p>

\[\binom{1/2}{3} = \frac{\frac12 !}{3! \, (-\frac52) !} = \frac{???}{3 \times ??} ,\]

<p>which doesn’t work at all, since the factorial doesn’t make sense for non-integer arguments. (Admittedly, you can usually get around this one with the Gamma function.)</p>

<h3 id="5-comparison-with-the-multiset-coefficient">5. Comparison with the multiset coefficient</h3>

<p>There is also another coefficient that we often study alongside the binomial coefficient: the <em>multiset coefficient</em>. This is the number of ways of choosing $k$ items from a set of $n$ items <em>if you’re allowed to pick each item more than once</em>. Think of how many different handfuls of 6 chocolates you can pick out from a tub of Celebrations: you might get 3 Bounties, 2 Mars bars and Twix, for example.</p>

<p>The multiset coefficient can be written using the <em>rising factorial</em></p>

\[n^{\overline{k}} = n(n+1) \cdots (n+k-1) ,\]

<p>where here the terms are going up by 1 each time. Then the multiset coefficient is</p>

\[\bigg(\kern-0.4em\dbinom{n}{k}\kern-0.4em\bigg)  = \frac{n^{\overline{k}}}{k!} ,\]

<p>where we are using double-brackets for the multiset coefficient, compared to single-brackets for the binomial coefficient.</p>

<p>So writing these Formula A-style, we have a delightful symmetry between the binomial and multiset coefficients:</p>

\[\binom{n}{k} = \frac{n^{\underline{k}}}{k!} \qquad \bigg(\kern-0.4em\dbinom{n}{k}\kern-0.4em\bigg)  = \frac{n^{\overline{k}}}{k!} .\]

<p>But writing them Formula B-style gives the much less pleasing to the eye</p>

\[\binom{n}{k} = \frac{n!}{k! \, (n-k)!} \qquad \bigg(\kern-0.4em\dbinom{n}{k}\kern-0.4em\bigg) = \frac{(n+k-1)!}{k!\,(n-1)!} .\]

<p>Yuck.</p>

<h3 id="but-what-about-the-symmetry-relation">But what about the symmetry relation?</h3>

<p>The Formula B-ers might have a case with the following point, though: What about the symmetry relation? The <em>symmetry relation</em> is the result</p>

\[\binom{n}{k} = \binom{n}{n-k}  .\]

<p>The B-ers would argue that this expression is very obvious with their Formula, since</p>

\[\binom{n}{k} = \frac{n!}{k! \, (n-k)!} = \frac{n!}{(n-k)! \, k!} = \binom{n}{n-k} .\]

<p>They would argue that this is not at all easy to see from Formula A. Is it really true that</p>

\[\frac{n^{\underline{k}}}{k!} = \frac{n^{\underline{n-k}}}{(n-k)!} ?\]

<p>I sort of see the point. But I would argue that Formula B makes this <em>too obvious</em>. The symmetry relation is a deep and important fact, that deserves a proper explanation; just saying “It’s trivial: Formula B says so!” denies us the opportunity to understand <em>why</em> the symmetry relation holds.</p>

<p>To understand why it holds, think of taking $n$ balls. How many ways we can paint $k$ of the balls red and the remaining $n-k$ blue? Well, we could either choose the $k$ red balls $\binom{n}{k}$ ways, painting the left-over balls blue, or we could choose the $n-k$ blue balls $\binom{n}{n-k}$ ways, and paint the left-over balls red. Since these count the same thing, they must be equal. This is the correct way to to understand the symmetry relation, not just finding some apparent coincidence in your formula. So, paradoxically, I think that Formula A making the symmetry relation less obvious is actually a <em>benefit</em>, not a drawback.</p>]]></content><author><name></name></author><category term="maths" /><summary type="html"><![CDATA[The binomial coefficient $\binom{n}{k}$, pronounced “$n$ choose $k$”, is the number of ways of choosing a collection of $k$ objects from a set of $n$ objects.]]></summary></entry><entry><title type="html">The geometric distribution starts from 0</title><link href="https://mpaldridge.github.io/blog/geometric.html" rel="alternate" type="text/html" title="The geometric distribution starts from 0" /><published>2025-08-19T00:00:00+00:00</published><updated>2025-08-19T00:00:00+00:00</updated><id>https://mpaldridge.github.io/blog/geometric-0</id><content type="html" xml:base="https://mpaldridge.github.io/blog/geometric.html"><![CDATA[<p>You keep rolling a dice until you get a six: how many rolls does this take?</p>

<p>More generally, you have a sequence of “trials”, each of which succeeds independently with probability $p$ or fails with probability $1-p$. You keep running these trials until you get a success. How many trials does this take?</p>

<p>Mathematicians call this number of trials needed a <strong>geometric distribution</strong>. But there’s actually a bit of disagreement about exactly what the geometric distribution <em>is</em>. There are two different conventions:</p>

<ul>
  <li>
    <p><strong>Convention 1</strong> is that the geometric distribution counts the number of trials up to and including the first success. So if I roll my dice and get three, one, two, two, six, then I rolled the dice 5 times altogether, including the final six, so $X = 5$. The possible numbers of total trials are $1, 2, 3, \dots$, starting from 1. The probability of performing exactly $x$ trials up to and including the first success is $p_1(x) = (1-p)^{x-1} \, p$ for $x = 1, 2, \dots$, since you need $x-1$ failures followed by the $x$th trial being a success.</p>
  </li>
  <li>
    <p><strong>Convention 0</strong> is that the geometric distribution counts the number of failures before the first success. So if I roll my dice and get three, one, two, two, six, then I rolled 4 non-sixes before the six, so $X = 4$. The possible numbers of failures are $0, 1, 2, \dots$, starting from 0. The probability of getting exactly $x$ failures before the first success is $p_0(x) = (1-p)^x \, p$ for $x = 0, 1, \dots$, since you need $x$ failures followed by a success.</p>
  </li>
</ul>

<p>A Convention-1 geometric distribution can be turned into a Convention-0 geometric distribution by subtracting 1; a Convention-0 geometric distribution can be turned into a Convention-1 geometric distribution by adding 1. So these aren’t, deep down, substantially different objects. But it is usually important that people know which convention you’re talking about.</p>

<p>Which convention is more popular?</p>

<ul>
  <li>Convention 1 is used by:
    <ul>
      <li><em>Probability</em> by Durrett; <em>Probability</em> by Grimmett and Walsh; <em>Probability and Random Processes</em> by Grimmett and Stirzaker; <em>Introductory Probability</em> by Grinstead and Snell; <em>Probability and Computing</em> by Mitzenmacher and Upfal; <em>Introduction to Probability Models</em> by Ross; <em>Elementary Probability</em> by Stirzaker; <em>Weighing the Odds</em> by Williams</li>
      <li><a href="https://mpaldridge.github.io/math1710/">My MATH1710 notes</a>*; my successor’s MATH1700 notes*; <a href="https://vittoriasilvestri.wordpress.com/wp-content/uploads/2019/05/probabilityia.pdf">Vittoria Silvestri’s Cambridge notes</a>; Oliver Johnson’s Bristol notes</li>
      <li>Every single one of the half-dozen colleagues I asked this week</li>
      <li>Claude*; Microsoft Copilot</li>
    </ul>
  </li>
  <li>Convention 0 is used by:
    <ul>
      <li><em>Introduction to Probability</em> by Blitzstein and Hwang*</li>
      <li>The statistical programming language R</li>
      <li>My predecessor’s MATH1710 notes; <a href="https://www.statslab.cam.ac.uk/~rrw1/prob/index.html">Richard Weber’s Cambridge notes</a></li>
      <li><a href="https://mathworld.wolfram.com/GeometricDistribution.html">Wolfram MathWorld</a></li>
    </ul>
  </li>
  <li>Both conventions are given equal coverage by
    <ul>
      <li><a href="https://en.wikipedia.org/wiki/Geometric_distribution">Wikipedia</a></li>
      <li>ChatGPT; Google Gemini</li>
    </ul>
  </li>
</ul>

<p>(A * denotes that the source mentions the existence of the other convention.)</p>

<p>It seems that Convention 1 is more popular, perhaps almost overwhelmingly so. (Although actually Convention 0 did do a little better than I had expected.)</p>

<p>When <a href="https://mpaldridge.github.io/math1710/L11-binomial-geometric.html#geometric">I taught the geometric distribution</a> I was a strong Convention 1-er, although I did mention that the language R uses Convention 0, which I said I found very annoying. In the lectures, I think I said something along the lines of: “When I’m King of the World, I will force everyone to use the convention where the geometric distribution is the number of trials up to and including the first success. That this is not universally recognised is just further evidence of the fallen state of Mankind.”</p>

<p>In this blogpost I want to admit I was wrong. Over the past year or so, I’ve had a Damascene conversion, and I’m now fully on-board with Convention 0. (You can see my doubts first starting to bloom towards the end of <a href="https://mpaldridge.github.io/blog/falling-moments.html">this earlier blogpost</a>.) I want to explain why I now think that Convention 0 is better.</p>

<h2 id="why-start-from-1">Why start from 1?</h2>

<p>Before explaining why I changed my mind, let me try to recreate my former thought process about why Convention 1 might be preferable.</p>

<p>First, Convention 1 is the thing you actually want to know about. If I’m rolling a dice until getting a certain number, I want to know how many times I have to roll it all together, not how many unsuccessful rolls I’ll have before the successful one.</p>

<p>Second, under Convention 1, the expected number of trials up to and including the first success is $1/p$, while under Convention 2, the expected number of failed trials is $1/p - 1 = (1-p)/p$. The first expression is neater – especially in the “$n$ equally likely outcomes, of which one is a success” setting, where the Convention 1 expectation is $n$ and the Convention 2 expectation is $n - 1$.</p>

<p>To put these together, suppose I’m rolling a $d$-sided dice until getting a particular number. It seems both more useful and more pleasant to say “on average it will take $d$ rolls to succeed” than to say “on average it will take $d-1$ failed rolls before succeeding”.</p>

<h2 id="why-start-from-0">Why start from 0?</h2>

<p>I still have some sympathy with that point of view. But if we look at the <em>mathematical properties</em> of the two conventions, it’s clear that Convention 0 always has the nicer properties. Here are some examples I thought of.</p>

<p><strong>1. Thinning.</strong> To thin a random variable $X$ by a probability $a$, we think of $X$ as representing a number of items, each of which is independently kept with probability $a$ or discarded with probability $1-a$.</p>

<ul>
  <li>Convention 0: Thinning a Convention-0 geometric distribution gives another Convention-0 geometric distribution but with a different value of $p$.</li>
  <li>Convention 1: Thinning a Convention-1 geometric distribution gives a distribution not in any well-known family.</li>
</ul>

<p><strong>2. Compound Poisson.</strong> A compound Poisson distribution is a sum of Poisson-many IID copies of some distribution. We can think of this as receiving a Poisson number of deliveries, each of which contains a IID random number of items; the total number of items across all the deliveries is a compound Poisson distribution.</p>

<ul>
  <li>Convention 0: A Convention-0 geometric distribution is compound Poisson where the compounded distribution is a logarithmic distribution.</li>
  <li>Convention 1: A Convention-1 geometric distribution is not compound Poisson.</li>
</ul>

<p><strong>3. Mixed Poisson.</strong> A mixed Poisson distribution is a Poisson distribution where the rate parameter is itself chosen at random. We can think of the random rate parameter being how popular we are today, then the mixed Poisson distribution as the number of items we receive, which is Poisson conditional on our popularity.</p>

<ul>
  <li>Convention 0: A Convention-0 geometric distribution is mixed Poisson where the rate follows an exponential distribution.</li>
  <li>Convention 1: A Convention-1 geometric distribution is not mixed Poisson.</li>
</ul>

<p><strong>4. Infinite divisibility.</strong> A random variable is infinitely divisible if, for any $n$, it can be written as the sum of $n$ copies of an IID random variable $Y_n$. It is called discrete infinitely divisible if $Y_n$ takes only non-negative integer values.</p>

<ul>
  <li>Convention 0: A Convention-0 geometric distribution is infinitely divisible and discrete infinitely divisible.</li>
  <li>Convention 1: A Convention-1 geometric distribution is infinitely divisible but is not discrete infinitely divisible.</li>
</ul>

<p><strong>5. Factorial tilting.</strong> This one’s a bit more obscure. One way of defining the <a href="https://en.wikipedia.org/wiki/Exponential_tilting">exponential tilting</a> $X^{(s)}$ of $X$ is that the moment generating function $M$ of $X$ and the moment generating function $M^{(s)}$ of $X^{(s)}$ are related by $M^{(s)}(t) = M(t + s) / M(s)$. <a href="https://doi.org/10.1007/s10182-015-0250-z">Jørgensen and Kokonendji</a> define the “factorial tilting” $M^{[s]}$ as an alternative for discrete distributions, instead working with the factorial moment generating function $\Phi(t) = \mathbb E(1+t)^X$: the factorial moment generating function $\Phi$ of $X$ and the factorial moment generating function $\Phi^{[s]}$ of $X^{[s]}$ are related by $\Phi^{[s]}(t) = \Phi(t + s) / \Phi(s)$. This preserves, for example, the families of Poisson, Bernoulli, binomial and Hermite distributions.</p>

<ul>
  <li>Convention 0: The factorial tilting of a Convention-0 geometric distribution is another Convention-0 geometric distribution (for $s$ such that the factorial tilting exists).</li>
  <li>Convention 1: The factorial tilting of a Convention-1 geometric distribution is not in any well-known family.</li>
</ul>

<p>I think that’s 5–0 for Convention 0.</p>

<p><strong>Update:</strong> <em>I thought of another: the Convention-0 geometric is the equilibrium distribution of the <a href="https://en.wikipedia.org/wiki/M/M/1_queue">M/M/1 queue</a>; I can’t think of any sensible queueing model for which a Convention-1 geometric distribution is the equilibrium distribution.</em></p>

<h2 id="a-modest-proposal">A modest proposal</h2>

<p>Actually, though, I want to go further. I don’t just want to convert everyone to Convention 0. More controversially still, I want to change the parameter of the geometric distribution. Rather than using the success probability $p$ as the parameter, I want to use the <em>odds against success</em> $\theta = (1 - p)/p$.</p>

<p>Why such a bizarre choice? To do this, I want to put the geometric distribution within the wider family of <strong>negative binomial distributions</strong>. A negative binomial distribution has two parameters: $n$ and $p$ (or $n$ and $\theta$, I will shortly argue). The negative binomial distribution, at least to us Convention 0ers, counts the number of failures before the $n$th success. So, for example, if you roll a dice until getting a six for the tenth time, the number of non-sixes you rolled en route is negative binomial with $n = 10$ and $p = \frac{1}{6}$ (or $\theta = 5$). Setting $n = 1$ gets back the geometric distribution in the Convention 0 form, so the Convention-0 geometric slots in nicely as the first and most important example in the bigger family of negative binomials.</p>

<p>(None of my Convention 1-loving colleagues were willing to bite the bullet and admit the negative binomial should be the number of trials up to and including the $n$th success, with minimum value $n$. So maybe they’re all secret Convention 0ers like me, deep down.)</p>

<p>But it turns out that the negative binomial with $\theta$ as the odds against success behaves in a number of interesting ways as the “opposite” of the binomial distribution. The binomial distribution is the number of successes out of a fixed number $n$ of trials each of which succeeds with probability $\theta$. Remember that for the binomial $\theta$ is the success probability, but for the negative binomial $\theta$ is the odds against success.</p>

<p>So what are these interesting “opposites”?</p>

<p>(I’ll be using the notation $n^{\underline{k}} = n(n-1)\cdots(n-k+1)$ for the falling factorial and $n^{\overline{k}} = n(n+1)\cdots(n+k-1)$ for the rising factorial.)</p>

<p><strong>1. Probability mass function.</strong></p>

<ul>
  <li>The PMF of the binomial distribution is $\displaystyle \binom{n}{x} \theta^x (1 - \theta)^{n-x}$, where $\binom{n}{x} = n^{\underline{x}} / x!$ is the binomial coefficient.</li>
  <li>The PMF of the negative binomial distribution is $\displaystyle \left(\kern-0.4em\binom{n}{x}\kern-0.4em\right) \theta^{-x} (1 + \theta)^{-n-x}$, where $\left(\kern-0.2em\binom{n}{x}\kern-0.2em\right) = n^{\overline{x}} / x!$ is the multiset coefficient.</li>
</ul>

<p><strong>2. Expectation.</strong></p>

<ul>
  <li>The expectation of the binomial distribution is $n\theta$.</li>
  <li>The expectation of the negative binomial distribution is $n\theta$.</li>
</ul>

<p><strong>3. Variance.</strong></p>

<ul>
  <li>The variance of the binomial distribution is $n\theta(1-\theta)$.</li>
  <li>The variance of the negative binomial distribution is $n\theta(1+\theta)$.</li>
</ul>

<p><strong>4. Factorial moments.</strong> The $k$th factorial moment is $\mathbb EX^{\underline{k}} = \mathbb EX(X-1)\cdots(X - k + 1)$.</p>

<ul>
  <li>The $k$th factorial moment of the binomial distribution is $n^{\underline{k}} \,\theta^k$.</li>
  <li>The $k$th factorial moment of the negative binomial distribution is $n^{\overline{k}} \,\theta^k$.</li>
</ul>

<p><strong>5. Probability generating function.</strong> The probability generating function is $G_X(t) = \mathbb E\,t^X$.</p>

<ul>
  <li>The probability generating function of the binomial distribution is $(1 - \theta + \theta t)^n$.</li>
  <li>The probability generating function of the negative binomial distribution is $(1 + \theta - \theta t)^{-n}$.</li>
</ul>

<p><strong>6. Thinning</strong></p>

<ul>
  <li>The $a$-thinning of a binomial distribution keeps $n$ the same but changes the success probability from $\theta$ to $a\theta$.</li>
  <li>The $a$-thinning of a negative binomial distribution keeps $n$ the same but changes the odds against success from $\theta$ to $a\theta$.</li>
</ul>

<p>All these “opposites” results are much more pleasant than they would be if the negative binomial (and therefore the geometric) were parameterised by the success probability $p$ where $p = 1/(1 + \theta)$.</p>]]></content><author><name></name></author><category term="maths" /><summary type="html"><![CDATA[You keep rolling a dice until you get a six: how many rolls does this take?]]></summary></entry><entry><title type="html">Photos: Belfast</title><link href="https://mpaldridge.github.io/blog/belfast.html" rel="alternate" type="text/html" title="Photos: Belfast" /><published>2025-08-07T00:00:00+00:00</published><updated>2025-08-07T00:00:00+00:00</updated><id>https://mpaldridge.github.io/blog/belfast</id><content type="html" xml:base="https://mpaldridge.github.io/blog/belfast.html"><![CDATA[<p>Belfast and the northern coast of Northern Ireland, 3–6 August 2025</p>

<p><a href="/assets/photos/belfast/rotunda1.jpg" data-lightbox="gallery" data-caption="Rotunda at City Hall (1/2)">
  <img src="/assets/photos/belfast/thumbs/rotunda1.jpg" />
</a></p>

<p><a href="/assets/photos/belfast/bunny.jpg" data-lightbox="gallery" data-caption="Stained-glass bunny at City Hall">
  <img src="/assets/photos/belfast/thumbs/bunny.jpg" />
</a></p>

<p><a href="/assets/photos/belfast/rotunda2.jpg" data-lightbox="gallery" data-caption="Rotunda at City Hall (2/2)">
  <img src="/assets/photos/belfast/thumbs/rotunda2.jpg" />
</a></p>

<p><a href="/assets/photos/belfast/statue.jpg" data-lightbox="gallery" data-caption="Beacon of Hope sculpture">
  <img src="/assets/photos/belfast/thumbs/statue.jpg" />
</a></p>

<p><a href="/assets/photos/belfast/theorem.jpg" data-lightbox="gallery" data-caption="A road named after a theorem!">
  <img src="/assets/photos/belfast/thumbs/theorem.jpg" />
</a></p>

<p><a href="/assets/photos/belfast/chaplin.jpg" data-lightbox="gallery" data-caption="Metal Charlie Chaplin sculpture">
  <img src="/assets/photos/belfast/thumbs/chaplin.jpg" />
</a></p>

<p><a href="/assets/photos/belfast/helicopter.jpg" data-lightbox="gallery" data-caption="Helicopter at Crumline Road Gaol">
  <img src="/assets/photos/belfast/thumbs/helicopter.jpg" />
</a></p>

<p><a href="/assets/photos/belfast/giants-causeway.jpg" data-lightbox="gallery" data-caption="Giant's Causeway">
  <img src="/assets/photos/belfast/thumbs/giants-causeway.jpg" />
</a></p>

<p><a href="/assets/photos/belfast/lens-flare.jpg" data-lightbox="gallery" data-caption="Cliffs near Giant's Causeway (feat. lens flare)">
  <img src="/assets/photos/belfast/thumbs/lens-flare.jpg" />
</a></p>

<p><a href="/assets/photos/belfast/beach-house.jpg" data-lightbox="gallery" data-caption="Near White Park Bay (I think)">
  <img src="/assets/photos/belfast/thumbs/beach-house.jpg" />
</a></p>

<p><a href="/assets/photos/belfast/beach-cows.jpg" data-lightbox="gallery" data-caption="COWS ON DA BEACH">
  <img src="/assets/photos/belfast/thumbs/beach-cows.jpg" />
</a></p>

<p><a href="/assets/photos/belfast/village.jpg" data-lightbox="gallery" data-caption="Ballintoy">
  <img src="/assets/photos/belfast/thumbs/village.jpg" />
</a></p>

<p><a href="/assets/photos/belfast/castle.jpg" data-lightbox="gallery" data-caption="Kinbane Castle">
  <img src="/assets/photos/belfast/thumbs/castle.jpg" />
</a></p>

<p><a href="/assets/photos/belfast/flower.jpg" data-lightbox="gallery" data-caption="Botanic Gardens">
  <img src="/assets/photos/belfast/thumbs/flower.jpg" />
</a></p>

<p><a href="/assets/photos/belfast/pint.jpg" data-lightbox="gallery" data-caption="A pint of Belfast Black at the Crown Liquor Saloon">
  <img src="/assets/photos/belfast/thumbs/pint.jpg" />
</a></p>]]></content><author><name></name></author><category term="notmaths" /><summary type="html"><![CDATA[Belfast and the northern coast of Northern Ireland, 3–6 August 2025]]></summary></entry><entry><title type="html">Which election was the closest?</title><link href="https://mpaldridge.github.io/blog/close-votes.html" rel="alternate" type="text/html" title="Which election was the closest?" /><published>2025-05-02T00:00:00+00:00</published><updated>2025-05-02T00:00:00+00:00</updated><id>https://mpaldridge.github.io/blog/votes</id><content type="html" xml:base="https://mpaldridge.github.io/blog/close-votes.html"><![CDATA[<p>Last night, there was a very close byelection in Runcorn and Helsby. The result was</p>

<table>
  <thead>
    <tr>
      <th style="text-align: center"><em>Reform</em></th>
      <th style="text-align: center"><em>Labour</em></th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td style="text-align: center">12,645</td>
      <td style="text-align: center">12,639</td>
    </tr>
  </tbody>
</table>

<p>Very close! (In this and all results, I’ll only look at the top two candidates, and ignore any other votes.)</p>

<p>But was this closer than the most famous close election of recent times: the 2000 US presidential election in Florida? The result there was:</p>

<table>
  <thead>
    <tr>
      <th style="text-align: center">Bush</th>
      <th style="text-align: center">Gore</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td style="text-align: center">2,912,790</td>
      <td style="text-align: center">2,912,253</td>
    </tr>
  </tbody>
</table>

<p>So which was closer? Well, that depends. How do we measure the closeness of elections?</p>

<p>The simplest way would be just to look at the <strong>absolute difference</strong> or the “winning margin” <em>d</em>: that is, the number <em>d</em> of extra votes the winning candidate got over the losing candidate. Smaller differences are more impressively tight elections: a small absolute difference means a very close election, while a big absolute difference is not a close election. So how does that work out here?</p>

<table>
  <thead>
    <tr>
      <th style="text-align: center">Reform</th>
      <th style="text-align: center">Labour</th>
      <th style="text-align: center">abs. diff.</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td style="text-align: center">12,645</td>
      <td style="text-align: center">12,639</td>
      <td style="text-align: center">6</td>
    </tr>
  </tbody>
</table>

<table>
  <thead>
    <tr>
      <th style="text-align: center">Bush</th>
      <th style="text-align: center">Gore</th>
      <th style="text-align: center">abs. diff.</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td style="text-align: center">2,912,790</td>
      <td style="text-align: center">2,912,253</td>
      <td style="text-align: center">537</td>
    </tr>
  </tbody>
</table>

<p>Well, that solves it! The Runcorn byelection was decided by 6 votes, while Florida 2000 was decided by 537 votes. So Runcorn was much, much closer!</p>

<p>But, wait. These two elections were of very different sizes. There were about 25,000 voters in Runcorn, between the two biggest parties, but almost 6 million voters in Florida! Surely that needs be taken into account? Otherwise, we could say that Manchester United’s 3–0 thrashing of Athletico Madrid last night (absolute difference: 3) was even closer than the byelection.</p>

<p>So perhaps it makes more sense to look at the <strong>relative difference</strong> – that is, by what <em>percentage</em> one candidate beat the other one, or the absolute difference <em>d</em> divided by the total number of votes <em>n</em>. (Again, <em>n</em> will still just be the total of number of votes among the two best candidates.)</p>

<table>
  <thead>
    <tr>
      <th style="text-align: center">Reform</th>
      <th style="text-align: center">Labour</th>
      <th style="text-align: center">abs. diff.</th>
      <th style="text-align: center">rel. diff.</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td style="text-align: center">12,645</td>
      <td style="text-align: center">12,639</td>
      <td style="text-align: center">6</td>
      <td style="text-align: center">0.024%</td>
    </tr>
  </tbody>
</table>

<table>
  <thead>
    <tr>
      <th style="text-align: center">Bush</th>
      <th style="text-align: center">Gore</th>
      <th style="text-align: center">abs. diff.</th>
      <th style="text-align: center">rel. diff.</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td style="text-align: center">2,912,790</td>
      <td style="text-align: center">2,912,253</td>
      <td style="text-align: center">537</td>
      <td style="text-align: center">0.009%</td>
    </tr>
  </tbody>
</table>

<p>So, both very close elections. But smaller results are better, still, so this time, it’s Flordia 2000 that wins: it’s reduced by a factor of two-and-a-bit compared to Runcorn, on this measure. Florida was closer!</p>

<h2 id="looking-again-at-relative-difference">Looking again at relative difference</h2>

<p>I think this is the result that most people would accept: closeness of elections is decided by relative (or percentage) difference between the top two candidates, so Flordia 2000 was closer.</p>

<p>But I want to think a bit more carefully about the relative difference: What does it mean, and what justification can we give for its use?</p>

<p>I propose that one way to think about the relative difference is the following.</p>

<p>Suppose we have 99 voters. Then there are 100 possible numerical results, from a 99–0 wipe-out for Red over Blue, to a 98–1 trouncing for Red over Blue, then 97–2, all the way through to a 0–99 wipe-out for Blue over Red. Suppose further that all 100 of those results are equally likely, coming up with 1% probability each. We could then come up with a kind of <a href="https://en.wikipedia.org/wiki/P-value">p-value</a>: <em>What is the probability (under this model) that the election result was as close as this or closer?</em></p>

<p>Suppose in our example that the Red party wins 51-48. Then, out of the 100 possible outcomes, there were four outcomes that would have been as close as this or closer: 51–48 itself, plus 50–49, 49–50, and 48–51. (In the latter two, Blue beat Red.) So the “p-value” (or “somewhat p-value-like quantity”) is 4/100 or 0.04.</p>

<p>So now consider an election with <em>n</em> voters and a difference of <em>d</em>. What’s the p-value here? The answer is that there are <em>d</em> + 1 outcomes as close as this or closer, and <em>n</em> + 1 possible outcomes. So the answer is (<em>d</em> + 1) / (<em>n</em> + 1).</p>

<p>[<em>Optional proof:</em> To see this, we need to count up all the results between “this result” and “the opposite result”, where the other candidate wins by the same amount. To count up these we can imagine distributing the winner’s votes to the loser: we could distribute 0 (current result) or 1 (two votes closer in the margin – unless there was only one vote in it to start with), or 2 votes, or 3, up to <em>d</em> votes; at the point we distribute <em>d</em> votes, we get the “opposite” result, the equal “closeness” as the original result, and any further distribution gives a less-close result with a bigger victory for the originally-losing candidate.]</p>

<p>This p-value we have justified, (<em>d</em> + 1) / (<em>n</em> + 1), is very nearly the absolute difference <em>d</em>/<em>n</em>; there’s just an extra “plus 1” on the top and bottom. So, my first proposal is not to look at the relative difference <em>d</em>/<em>n</em>, but rather the <strong>adjusted relative difference</strong> (<em>d</em> + 1) / (<em>n</em> + 1).</p>

<p>For all but the tiniest electorates, replacing <em>n</em> by <em>n</em> + 1 makes almost no difference. For extremely close elections, though, replacing <em>d</em> by <em>d</em> + 1 can effect things: this is a slight extra penalty for the smaller election. (Like Runcorn!)</p>

<table>
  <thead>
    <tr>
      <th style="text-align: center">Reform</th>
      <th style="text-align: center">Labour</th>
      <th style="text-align: center">rel. diff.</th>
      <th style="text-align: center">adj. rel. diff.</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td style="text-align: center">12,645</td>
      <td style="text-align: center">12,639</td>
      <td style="text-align: center">0.024%</td>
      <td style="text-align: center">0.028%</td>
    </tr>
  </tbody>
</table>

<table>
  <thead>
    <tr>
      <th style="text-align: center">Bush</th>
      <th style="text-align: center">Gore</th>
      <th style="text-align: center">rel. diff.</th>
      <th style="text-align: center">adj. rel. diff.</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td style="text-align: center">2,912,790</td>
      <td style="text-align: center">2,912,253</td>
      <td style="text-align: center">0.00922%</td>
      <td style="text-align: center">0.00924%</td>
    </tr>
  </tbody>
</table>

<p>Here, our adjustment slightly increased the score of the smaller Runcorn byelection, but barely changed the much bigger Florida election. Now, the Florida 2000 score is reduced by about a factor of 3 compared to Runcorn.</p>

<p>To put it another way, under this “each result equally likely” model:</p>

<ul>
  <li>a result like the Runcorn byelection would happen once every 3,600 elections;</li>
  <li>a result like Florida 2000 would happen once every 11,000 elections.</li>
</ul>

<p>So the Runcorn byelection result is (under this model) about 3 times as likely as the Florida 2000 result.</p>

<p>Before we move on, one last argument for the adjusted relative difference, with the “plus 1”s, over the standard relative difference. Consider two elections: in the first, there are four voters, and it’s a 2–2; in the second, there are four million voters, and, astonishingly, it’s an <em>exact</em> 2 million – 2 million tie! I guess you could say that these are both “perfectly close” results, as verified by their ideal relative differences of 0. But I think most people would regard the 2 million – 2 million tie as way more impressive. And that is indeed what shows up with the adjusted relative difference: the first score is (0 + 1)/(4 + 1) = 0.2, while the second is 1/4,000,001 = 0.00000025, an enormous reduction by a factor of almost a million.</p>

<h2 id="a-modest-proposal">A modest proposal</h2>

<p>It was nice that the mathematical justification we gave above recovered (a slight adjustment of) the relative difference statistic that everyone uses anyway. But was that mathematical justification <em>actually</em> convincing, or was I pulling the wool over your eyes?</p>

<p>Well, I wasn’t being deceptive, but there is part of the argument I find unconvincing. It’s where I said that we could consider all 100 results from 99–0 to 0–99 equally likely. Is that a reasonable assumption? If I tossed 99 coins, getting 99 heads and 0 tails would be extraordinarily unlikely – about a one in 600 billion billion billion chance – but getting a 50–49 victory for heads over tails happens quite regularly – about one in every 13 goes.</p>

<p><img src="../assets/img/votes.png" alt="" /></p>

<p>(This is because there’s only one way for 99 coins to land all heads, but there are many ways for 99 coins to land with a 50/49 split. See <a href="https://en.wikipedia.org/wiki/Binomial_distribution">the Wikipedia page on the “binomial distribution”</a> for more on this.)</p>

<p>So we should take this into account when calculating our p-value. That is, we should instead caculate the probability of getting a result as close as this or closer with this “coin-tossing” model, rather than the previous “equally likely scores” model. I propose to call the p-value calculated with the coin-toss model the “Frodsham score” (after <a href="https://www.theguardian.com/politics/2024/oct/27/labour-mp-mike-amesbury-filmed-punching-man-to-the-ground-in-cheshire">the place where the infamous punch occured</a> that led to the Runcorn byelection – although the “<a href="https://www.americaexplained.org/what-is-a-hanging-chad.htm">chad</a> score” would also work).</p>

<p>The bad news is that, while there is a formula to calculate the Frodsham score, it’s not a very pleasant one: if the loser gets <em>a</em> votes and the winner <em>b</em> votes, for a total of <em>n</em> = <em>a</em> + <em>b</em> votes, then the Frodsham score is</p>

\[F = 2^{-n} \sum_{k=a}^b \binom{n}{k}\]

<p>where that thing in brackets is the “<a href="https://en.wikipedia.org/wiki/Binomial_coefficient">binomial coefficient</a>” (read “<em>n</em> choose <em>k</em>”, and famous from <a href="https://en.wikipedia.org/wiki/Pascal%27s_triangle">Pascal’s triangle</a>). Pleasantness as a formula aside, though, the Frodsham score is easily calculated on a computer. We get:</p>

<table>
  <thead>
    <tr>
      <th style="text-align: center">Reform</th>
      <th style="text-align: center">Labour</th>
      <th style="text-align: center">adj. rel. diff.</th>
      <th style="text-align: center">Frodsham</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td style="text-align: center">12,645</td>
      <td style="text-align: center">12,639</td>
      <td style="text-align: center">0.028%</td>
      <td style="text-align: center">3.5%</td>
    </tr>
  </tbody>
</table>

<table>
  <thead>
    <tr>
      <th style="text-align: center">Bush</th>
      <th style="text-align: center">Gore</th>
      <th style="text-align: center">adj. rel. diff.</th>
      <th style="text-align: center">Frodsham</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td style="text-align: center">2,912,790</td>
      <td style="text-align: center">2,912,253</td>
      <td style="text-align: center">0.00922%</td>
      <td style="text-align: center">18%</td>
    </tr>
  </tbody>
</table>

<p>To put it another way, under this “coin tossing” model:</p>

<ul>
  <li>a result like the Runcorn byelection would happen once every 28 elections;</li>
  <li>a result like Florida 2000 would happen once every 6 elections.</li>
</ul>

<p>Runcorn wins again! The Florida 2000 result occurs about 5 times as often.</p>

<p>A final mathematical aside: while the exact formula for the Frodsham score is unpleasant, when the absolute difference <em>d</em> is small and the number of voters <em>n</em> is large, the approximation</p>

\[F \approx \sqrt{\frac{2}{\pi}} \, \frac{d+1}{\sqrt{n}} \approx 0.798 \, \frac{d+1}{\sqrt{n}}\]

<p>is pretty accurate:</p>

<table>
  <thead>
    <tr>
      <th style="text-align: center">Reform</th>
      <th style="text-align: center">Labour</th>
      <th style="text-align: center">Frodsham</th>
      <th style="text-align: center">approx. Frodsham</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td style="text-align: center">12,645</td>
      <td style="text-align: center">12,639</td>
      <td style="text-align: center">3.511%</td>
      <td style="text-align: center">3.512%</td>
    </tr>
  </tbody>
</table>

<table>
  <thead>
    <tr>
      <th style="text-align: center">Bush</th>
      <th style="text-align: center">Gore</th>
      <th style="text-align: center">Frodsham</th>
      <th style="text-align: center">approx. Frodsham</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td style="text-align: center">2,912,790</td>
      <td style="text-align: center">2,912,253</td>
      <td style="text-align: center">17.6%</td>
      <td style="text-align: center">17.8%</td>
    </tr>
  </tbody>
</table>

<p>And, of course, if you just want to compare elections with each other, you can ignore the common factor of 0.798 in the approximation. So my suggestion is this: Don’t take the percentage difference, by taking the difference (or, better, the difference plus 1) divided by n. Rather, divide by <em>the square root of n</em> instead!</p>]]></content><author><name></name></author><category term="maths" /><summary type="html"><![CDATA[Last night, there was a very close byelection in Runcorn and Helsby. The result was]]></summary></entry><entry><title type="html">Film review: Eternal Sunshine of the Spotless Mind</title><link href="https://mpaldridge.github.io/blog/eternal-sunshine.html" rel="alternate" type="text/html" title="Film review: Eternal Sunshine of the Spotless Mind" /><published>2025-02-12T00:00:00+00:00</published><updated>2025-02-12T00:00:00+00:00</updated><id>https://mpaldridge.github.io/blog/eternal-sunshine</id><content type="html" xml:base="https://mpaldridge.github.io/blog/eternal-sunshine.html"><![CDATA[<p><img src="../assets/img/eternal-sunshine.jpg" alt="" /></p>

<p>I think <em>Eternal Sunshine of the Spotless Mind</em> is probably my favourite film of all time. Certainly it’s the non-kids film I’ve watched the most. The first time I saw it was probably 2005 in my university dorm room one evening off a DVD borrowed from a friend, and I thought it was so great I watched it again the next morning before giving it back. And then for quite a while I used to watch it annually at about this time of year (the film has a long prologue set on Valentine’s day, before flashing back to most of the action happening the night before), before deciding that was maybe a bit too much of a depressed-single-person thing to do. But last night I watched it for probably the first time in at least five years, and definitely for the first time in the cinema.</p>

<p>My Grand Unified Theory of <em>Eternal Sunshine</em> goes something like this: Jim Carrey, Michel Gondry and Charlie Kaufman are respectively a generationally talented actor, director and writer, but they all have so many ideas gushing out of them that they really struggle to keep everything under control for two hours. Carrey is a supremely gifted physical comedian, but it gets tiresome after a few minutes. Gondry is the most galaxy-brained mad inventor working in film today, but all his best works (except this) are at music video length, and the feature films don’t really hang together. Kaufman builds these zany worlds and wild concepts, but – although others will argue against this – he has never really stuck the landing, for me. So combining the three ought to leave us with an unruly mess punctured by moments of brilliance. Yet somehow, miraculously, they all keep it super-restrained here; the wackiness is still there, and is still excellent, but it’s <em>just</em> poking through from under the surface rather than overwhelming everything.</p>

<p>How much does <em>Eternal Sunshine</em> benefit from being on the big screen? Well, I do think it is a film that looks beautiful, but it’s not visually stunning or astoundingly cinematic, so I didn’t feel I was watching a dramatically different film from the one I’ve seen so many times on the TV. But what does work much better is the sound. There are lots of in-Joel’s-memory scenes where the real-world conversations of the mind-erasers start bleeding in, and this is much clearer in full surround-sound. (Also, I don’t recall noticing before that the very first noise in the film is the scientists driving away in the morning.)</p>

<p>Various other thoughts on this rewatch (or, Random thoughts for a-few-days-before-Valentine’s day 2025):</p>

<ul>
  <li>Kate Winslet’s performance is still – still! – underrated in this.</li>
  <li>They are all superstars with pretty small parts, but I think I can argue with a straight face that these are life-time best performances from Tom Wilkinson, Mark Ruffalo, Elijah Wood and Kirsten Dunst. (Ruffalo breaks your heart just by taking his glasses off.)</li>
  <li>David Cross’s delivery of “I’m making! A birdhouse!” and Tom Wilkinson’s of “Paaaatrick, baaaaby-boy” are both legendary, as far as I’m concerned.</li>
  <li>Jon Brion’s score is excellent, but the bit where “Row, row, row your boat” fades into the piano is particularly gorgeous.</li>
  <li>I love the visual effect where Joel is eating the Chinese food while standing behind the TV, a TV that is showing him eat the food, as if it’s see-through. If you see what I mean?</li>
  <li>“Technically speaking, it <em>is</em> brain damage” is a very sharp line of dialogue.</li>
  <li>I reckon it’s between this and <em>Casablanca</em> for the film with the most quotable lines of dialogue: “Random thoughts for Valentine’s day 2004…” “Sand is overrated: it’s just tiny little rocks.” “‘Blessed are the forgetful, for they get the better even of their blunders.’” “Pope Alexander.” “Are we the dining dead?” The “I’m just a fucked-up girl…” speech.</li>
  <li>I’m not sure I believe Joel’s art would be quite as avant-garde, quite as <em>interesting</em>, as it is shown to be here.</li>
  <li>This is an almost perfect film – but I think there’s a plot hole I still haven’t managed to resolve to my satisfaction. In Joel’s memory – or dream? – Memory-Clementine says “Meet me in Montauk”. The next day Joel knocks off work and takes the train there. But how come Real-Clementine is there too? Is it just a coincidence?</li>
  <li>I’ve read quite a lot about this film, but I still don’t have a good handle on how the ending actually came about. I know that Kaufman originally wrote an ending where Joel and Clementine continually erase each other for their whole lives – which strikes me as the sort of ingenious but somewhat sour depressive note that has prevented me from fully enjoying his post-<em>Eternal Sunshine</em> writing. But the actual ending we have is just beautiful in its (let’s call it) realistic optimism. Whose idea was this? Who wrote “OK.” “OK?”, the greatest last lines of any film?</li>
</ul>

<p>I don’t know whether I was worried that I would cry at the film or that I wouldn’t. (Is it worse to appear embarrassingly vulnerable in public, or is it worse if a piece of art that has been very important to you no longer has the same emotional punch it once did?) But, for the record, my cry count was 3: “Row, row, row your boat,” as mentioned above; the ending, of course; and, most of all, the scene towards the end in the beachhouse – the key scene of the whole film.</p>

<p><iframe width="560" height="315" src="https://www.youtube.com/embed/HrGZsdczSBs?si=za7K4ythFJ5veSFt" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen=""></iframe></p>]]></content><author><name></name></author><category term="notmaths" /><summary type="html"><![CDATA[]]></summary></entry></feed>