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. The usual explanation is that a type case counts the letters a printer buys rather than the letters a telegram contains, and Vail did print a set of case counts, which is a motive rather than a derivation: nothing shows the signal lengths were assigned from that table.
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.
These ran in this browser when the page loaded. Each claim, whether it held, and the number behind it.
| claim | held | measured |
|---|---|---|
| E costs 1 unit, T costs 3, and O costs 11 | yes | a dash is three dots and the gap inside a letter is one, per ITU-R M.1677-1 sections 2.1 and 2.2; nothing here is a table of durations |
| the best assignment is exact, not the best one found: none of 325 swaps improves on it | yes | the rearrangement inequality says cheapest signal to commonest letter is optimal; this tries to beat it and cannot |
| on the sample, Morse's own assignment costs 661 units against a best possible 621, which is 6.4% over | yes | close to the best rearrangement of his own signals, which is a much stronger statement than some correlation with frequency |
| it saves 24.9% against handing out the same signals with no regard to frequency | yes | and it sits 8.1% of the way from the best arrangement to the worst one |
| all 26 letters carry a distinct signal | yes | the grading holds Morse's signals fixed and only rearranges which letter carries which, so they have to be distinguishable |
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 counts are Vail's own, and they do not add up
This said for a while that the counts came from secondary accounts rather than from anything Vail wrote. They do not. Vail prints them himself in The American Electro Magnetic Telegraph of 1845: considering Z as 2, we shall have A 85, B 16, C 30, D 44, E 120, F 25, G 17, H 64, I 80, J 4, K 8, L 40, M 30, N 80, O 80, P 17, Q 5, R 62, S 80, T 90, U 34, V 12, W 20, X 4, Y 20, Z 2.
He then computes with them, which is the part that makes them evidence rather than an anecdote.
Add the twenty-six up and they come to 1,069. Vail writes 1,177, twice, and the second time it is load-bearing: he gives 3,420 motions to send them, adds one motion per letter for spacing, and reaches 4,597, and 4,597 minus 3,420 is 1,177 exactly. So the total he worked from is not the total his own list makes. This page takes none of the numbers either way, and says both rather than picking the one that would look tidier. Where the missing 108 went is not something anybody here has established.
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
- ITU-R M.1677-1, International Morse code, for the signals and the timing
- Alfred Vail, The American Electro Magnetic Telegraph, 1845, Project Gutenberg. His own book, read here. The type-case counts quoted above are his, and so is the arithmetic they do not agree with.
- Secondary, and used as such: Alfred Vail, for the division of work with Morse, which the 1845 book is not a neutral witness to.
- Pride and Prejudice, Project Gutenberg, the text the quoted figures are counted from