Morse

Everyone says the common letters got the short signals. Nobody says how well.

The code, graded

letters 671Morse 4,007best arrangement 3,747over the best 6.94%

Sending this in Morse costs 4,007 dot-units. The best possible arrangement of Morse's own twenty-six signals would cost 3,747, so the code as it stands is 6.94% worse than itself rearranged. Against an assignment that ignored frequency altogether it saves 27.4%, which is what the counting in the print shop bought. It sits 7.6% of the way from the best arrangement to the worst.

Every letter, commonest first

Each row is what that letter costs, and in brackets what it would have cost if the signals were dealt out by frequency. Press one to hear it, at sixty milliseconds a dot.

    Where the code pays for it

      Checked when this page loaded: all 120 arrangements of a five-signal alphabet were tried, and the cheapest cost 306, which is what pairing them in order gives (306). That is the rule this page uses on twenty-six, where trying them all would mean 403,291,461,126,605,635,584,000,000 arrangements.

      A print shop in Morristown

      Alfred Vail is said to have walked into a newspaper office and counted the type in the compositor's case, on the reasoning that a printer already knows which letters English uses most: he has to buy them. E was the deepest box. So E became a single dot and T a single dash, and the letters nobody uses got the long ones.

      That is frequency-weighted coding, and it is 1838. Claude Shannon published the theory that explains why it works in 1948, and Bitwise on this site is the 1937 thesis he wrote first.

      How the grading works, and what it does not claim

      Take Morse's twenty-six signals and leave them exactly as they are. Now ask what the best possible assignment of those same signals to letters would cost. The answer needs no searching: give the cheapest signal to the commonest letter, the next cheapest to the next commonest, and so on. Any other pairing can be improved by swapping two of them, which is the rearrangement inequality, and the machine above checks that claim by brute force on a small alphabet when it loads.

      This is deliberately not a comparison with the theoretical minimum, and not with an optimal Huffman code. Both of those are free to invent signals Morse never had, and both give larger figures that get quoted as though they were this one. Holding the signal set fixed isolates the only decision Vail actually made: which letter gets which.

      The answer, on ordinary English

      On the archived copy of Pride and Prejudice this page cites, counting the 563,924 letters between the Project Gutenberg start and end markers, Morse costs 6.69% more than the best arrangement of its own signals. Against an assignment that ignored frequency altogether it saves 26.1%. It sits 7.8% of the way from the best possible arrangement to the worst.

      So the print shop bought most of what was there to buy, and left a little on the table. Both halves of that are worth saying, and only one of them usually is.

      The letter that costs the most is O

      O is the fourth commonest letter in that text and carries three dashes, eleven units, with eighteen of the twenty-six signals cheaper. Y holds the single most expensive signal in the alphabet while being middling common, which is worse per letter and cheaper overall because Y is rarer. There is no record of why, and the honest guess is that a type case counts the letters a printer buys rather than the letters a telegram contains.

      Which Morse this is

      The code above is International Morse, which the ITU still publishes as Recommendation M.1677-1 and which is what anybody now means by Morse. It is not the code Vail built in 1838. American Morse had different signals for about half the alphabet and used spaces inside some characters, and it is the one the type-case story is actually about. The idea is 1838 and the code measured here was settled in 1865, which is why the date on this page is written as a pair.

      An alphabet is always larger than the budget you have for it, and every code on this chronology pays that bill somewhere. Morse pays in time, which is the one currency a fixed-width code cannot spend. Fifty years later Baudot gave every letter the same five units, and the payment moved to punched holes.

      What is real here, and what is not

      The code measured is not the code in the story

      International Morse, standardised in 1865, is what is graded above. Alfred Vail's American Morse of 1838 differs in roughly half its letters and puts spaces inside some of them, so its cost model needs its own sourcing before it could be graded the same way. Measuring one code and dating the page by the other would be exactly the kind of quiet error this studio exists to avoid, so this says which is which rather than blurring them.

      The type case story rests on retelling

      That Vail counted type in a Morristown print shop is repeated everywhere and the specific counts that go with it come from secondary accounts rather than from anything Vail wrote. The page uses the story to explain a motive and takes none of its numbers, which is why none of them appears anywhere on it.

      Gaps between letters and words are left out

      The ITU sets the space between letters at three dots and between words at seven. Neither depends on which signal a letter carries, so both are identical under every assignment compared here and would add the same constant to each side. Leaving them out changes no comparison and keeps the arithmetic something you can check by hand.

      The sound is the cost, and nothing more

      Pressing a letter plays it at sixty milliseconds a dot, which is twenty words a minute by the usual reckoning, with the ITU's ratios: a dash is three dots and the gap inside a letter is one. That is there because the quantity this page measures is a duration, and holding E against O in the ear is the same fact by a shorter route. The tone is a plain sine wave and the pitch means nothing.

      What is still missing is everything else. No key, no sounder, no operator's fist, no drift, no noise, and no word gaps: the page plays one letter at a time because one letter is the thing being priced. A real operator's rhythm is most of what Morse was in practice and none of it is here.

      Frequency is whatever you paste

      No letter frequencies are stored on this page. They are counted from the text in the box, so the grade is a fact about your text rather than about English in general. Paste something short and the numbers move a long way; the figures quoted in the prose come from a novel, and say so.

      Sources