Uncategorized

Decoding a grid square

I saw a reference last night to the grid square EL29fx and wanted to figure out where that is. There are many programs that will do this for you, but I wanted to do it by hand.

I wrote about how grid squares work a year ago, but I was rusty on the details, so this morning I went back and reread my earlier post.

Parsing a locator

The system used to create grid squares in amateur radio is the Maidenhead Locator System. Last year I wrote about why the system works the way it does. Here I will recap how the system works but refer you to the earlier post for the motivation behind the design choices.

First of all, the Maidenhead system interleaves the longitude and latitude information. So in the square EL29fx, the longitude information is (E, 2, f) and the latitude information is (L, 9, x). The first two characters, EL, gives a rough location, a “field.” Then the next two characters, 29, refine the location to a “square.” The last two, fx, narrow the square down to a “subsquare.”[1]

Finding the field

The first character in the grid square specifies a range of longitude east of the International Date Line [2]. Each letter represents a range of 20° longitude: A for 0 to 20° longitude, B for 20° to 40°, etc. So E represents 80° to 100° longitude east of the antemeridian or 260° to 280° east of the prime meridian.

The second character in the grid square represents latitude north of the south pole in increments of 10°. So L represents 110° to 120° north of the south pole, or 20° to 30° north of the equator.

Together, EL tells us we’re looking at some place 260° to 280° E and 20° to 30° N, i.e. somewhere in Mexico or the US Gulf Coast.

Finding the square

The two digits in the middle of a grid square divide the field into 10 parts in both directions. Since a field is 20° wide and 10° tall, the first digit represents multiples of 2° latitude and the second digit represent multiples of 1° latitude.

So if we look at EL29, we know our location is between 264° and 266° E and between 29° and 30° N, which is somewhere around Houston, Texas

Finding the subsquare

A subsquare divides a square into 24 parts in each direction. So a subsquare is 5 minutes of longitude wide and 2.5 minutes of latitude high.

The f in EL29fx refines the longitude is 264° 25′ E (95° 35′ W) and the x refines the latitude is 29° 55′ N. This narrows the location to somewhere in northwest Houston.

Northwest Houston

[1] There’s no significance to the case of the letters other than as a reminder that the first and second pair of letters are interpreted differently.

[2] Technically, degrees east of 180th meridian, a.k.a. the antemeridian, which mostly coincides with the International Date Line. The latter zigzags a little to avoid splitting island groups.

New Twitter account: ElementFact

I started a new Twitter account this morning: @ElementFact. I’m thinking the account will post things like scientific facts about each element but also some history around how the element was discovered and named and other lore associated with the element.

@ElementFact icon

We’ll see how this goes. I’ve started many Twitter accounts over the years. Some have taken off and some have not.

Six months ago I started @TensorFact as an experiment to see what would happen with a narrowly focused account. It did moderately well, but I ran out of ideas for content. This will be the last week for that account.

You can see a list of my current Twitter accounts here.

Why target ads at pregnant women

I’m listening to a podcast interviewing Neil Richards, the author of Why Privacy Matters. Richards makes a couple interesting points about the infamous example of Target figuring out which women were pregnant based on their purchase history.

First, pregnancy is a point at which women are open to trying new things. So if a company can get a woman to buy a baby stroller at their store, they may be able to get her to remain a customer for years to come. (Richards mentioned going off to college as another such milestone, so a barrage of advertising is aimed at first-year college students.)

Second, women understandably freaked-out over the targeted ads. So Target hid the ads in with irrelevant ads. They might show a woman ads for lawnmowers and baby wipes. That way the baby wipe ads didn’t seem so on-the-nose. The target audience would see the ad without feeling like they’re being targeted.

Just to be clear, I’m not writing this post to offer how-to advice for doing creepy advertising. The info here is presumably common knowledge in the advertising industry, but it’s not common knowledge for the public.

French palindromes and Morse code

I got an email from a student in France who asked about a French counterpart to my post on Morse code palindromes, and this post is a response to that email.

Palindromes

A palindrome is a word that remains the same when the letters are reversed, like kayak. A Morse code palindrome is a word that remains the same when its Morse code representation is reversed.

The word kayak is not a Morse code palindrome because its Morse code representation

    -.- .- -.-- .- -.-

when reversed becomes

    -.- -. --.- -. -.-

which is the Morse code for knqnk.

The word wig is a palindrome in Morse code because

    .-- .. --.

reads the same in reverse.

French distinctives

Now what about French? I saved the script I wrote to find Morse palindromes in English, and I ran it on the French dictionary located at

    /usr/share/dict

on my Linux box.

I thought I’d have to modify the script because French uses characters in addition to the 26 letters of the Roman alphabet, such as ç, a ‘c’ with a cedilla. There is a Morse code for ç

    -.-..

but its reverse is not a letter.

It’s not clear exactly what is “French Morse code” because there are a number of code values that could be used in French (or English) to represent letters with diacritical marks.

The code for é is itself a palindrome, so I didn’t need to modify my script for it. As far as I know, there are no codes for accented letters which are valid letters when reversed, except for ü whose code is the opposite of z. But there are no Morse palindromes in French if you add ü.

Results

See this file for complete results. Some of these words remain the same when translated to Morse, reversed, and translated back, such as sans. Others, are pairs that of valid words but not the same word, such as ail and fin.

Related posts

Circular slide rule

I explained the basics of how a slide rule works in the previous post. But how does a circular slide rule work?

Mr. Spock holding an E6B circular slide rule

Apparently the prop Mr. Spock is holding is an E6B aircraft slide rule. It includes a circular slide rule and more functionality.

Start with an ordinary straight slide rule, with each bar labeled 1 on the left and 10 on the right end. Now imagine bending this into a circle so that you now have two concentric circles. For x between 1 and 10, the label for x is located at

log10 x × 360°.

Suppose you want to multiply x and y, and xy is less than 10, i.e. log10 x + log10 y < 1. Then the multiplication procedure works exactly analogously to how it would have with a straight slide rule. Line up the 1 of the inner ring with the position of x on the outer ring. The position of y on the inner ring lines up with xy on the outer ring because it is at position

log10 x × 360° + log10 y × 360° = log10 xy × 360°.

But what if xy > 10, i.e. log10 x + log10 y > 1? In that case the y on the inner ring is at position

(log10 x + log10 y) × 360°- 360° = (log10 x + log10 y – 1) × 360°

which is equal to

(log10 x + log10 y – log10 10) × 360° = log10 (xy/10) × 360°

and so the y on the inner ring is aligned with the position labeled xy/10. As we noted in the previous post, slide rules only give you the significand (mantissa) of the result, so a slide rule doesn’t know the difference between xy and xy/10. That’s up to you to keep up with.

E6B Flight Computer

Update: After first posting this article, I bought an E6B flight computer from Amazon for about $14. I bought the paper version because I’m certainly not going to wear it out. But if you’d like a nicer one, they make the same product in metal.

Here’s a photo of mine:

E6B analog flight computer

You can slide the horizontal piece out and essentially have a circular slide rule with some extra markings.

Frequency shift keying (FSK) spectrum

This post will look encoding digital data as an analog signal using frequency shift keying (FSK), first directly and then with windowing. We’ll look at the spectrum of the encoded signal and show that basic FSK uses much less bandwidth than direct encoding, but more bandwidth than FSK with windowing.

Square waves

The most natural way to encode binary data as an analog signal would be represent 0s and 1s by a sequence of pulses that take on the values 0 and 1.

A problem with this approach is that it would require a lot of bandwidth.

In theory a square wave has infinite bandwidth: its Fourier series has an infinite number of non-zero coefficients. In practice, the bandwidth of a signal is determined by how many Fourier coefficients it has above some threshold. The threshold would depend on context, but let’s say we ignore Fourier components with amplitude smaller than 0.001.

As I wrote about here, the nth Fourier sine series coefficients for a square wave is equal to 4/nπ for odd n. This means we would need on the order of 1,000 terms before the coefficients drop below our threshold.

Frequency shift keying

The rate of convergence of the Fourier series for a function f depends on the smoothness of f. Discontinuities, like the jump in a square wave, correspond to slow convergence, i.e. high bandwidth. We can save bandwidth by encoding our data with smoother functions.

So instead of jumping from 0 to 1, we’ll encode a 0 as a signal of one frequency and a 1 as a signal with another frequency. By changing the frequency after some whole number of periods, the resulting function will be continuous, and so will have smaller bandwidth.

Suppose we have a one second signal f(t) that is made of half a second of a 4 Hz signal and half a second of a 6 Hz signal, possibly encoding a 0 followed by a 1.

What would the Fourier coefficients look like? If we just had a 4 Hz sine wave, the Fourier series would have only one component: the signal itself at 4 Hz. If we just had a 6 Hz sine wave, the only Fourier component would again be the signal itself. There would be no sine components at other frequencies, and no cosine components.

But our signal patched together by concatenating 4 Hz and 6 Hz signals has non-zero cosine terms for every odd n, and these coefficients decay like O(1/n²).

Our Fourier series is

f(t) = 0.25 sin 8πt + 0.25 sin 12πt + 0.0303 cos 2πt + 0.1112 cos 6πt – 0.3151 cos 12πt + 0.1083 cos 10πt + …

We need to go out to 141 Hz before the coefficients drop below 0.001. That’s a lot of coefficients, but it’s an order of magnitude fewer coefficients than we’d need for a square wave.

Pulse shaping

Although our function f is continuous, it is not differentiable. The left-hand derivative at 1/2 is 8π and the right-hand derivative is 12π. If we could replace f with a related function that is differentiable at 1/2, presumably the signal would require less bandwidth.

We could do this by multiplying both halves of our signal by a windowing function. This is called pulse shaping because instead of a simple sine wave, we change the shape of the wave, tapering it at the ends.

Let’s using a cosine window because that’ll be easy; in practice you’d probably use a different window [1].

Now our function is differentiable at 1/2, and its Fourier series converges more quickly. Now we can disregard components above 40 Hz. With a smoother windowing function the windowed function would have more derivatives and we could disregard more of the high frequencies.

Related posts

[1] This kind of window is called a cosine window because you multiply your signal by one lobe of a cosine function, with the peak in the middle of the signal. Since we’re doing this over [0. 1/2] and again over [1/2, 1], we’re actually multiplying by |sin 2πt|.

Approximating the range of normal samples

On Monday I wrote a blog post that showed you can estimate the standard deviation of a set of data by first computing its range and then multiplying by a constant. The advantage is that it’s easy to compute a range, but computing a standard deviation in your head would be tedious to say the least.

The problem, or the interesting part, depending on your perspective, is the constants dn you have to multiply the range by.

Yesterday before work I wrote a blog post about a proposed approximation dn and yesterday after work I wrote a post on the exact values.

There have been a couple suggestions in the comments for how to approximate dn, namely √n and log n. There’s merit to both over different ranges.

Here’s a plot of dn and √n. You can see that √n is an excellent approximation to dn for n between 3 and 10: the gold and blue dots overlap. But for larger n, √n grows too fast. It keeps going while dn sorta plateaus.

For larger n, log n is a better approximation to dn. When n = 100, the square root approximation is about twice the exact value, but the log approximation if fairly close. The error in the log approximation seems to be decreasing slowly, maybe going to zero or to a small constant.

There are more accurate approximations out there. In 1958, Gunnar Blom [1] published the approximation

E(r, n) = - \Phi^{-1}\left( \frac{r - \alpha}{n - 2\alpha + 1} \right)

You can get good results for moderately large n by taking α = 0.375, and you can get even better results by adjusting α over various ranges of r and n.

As I wrote last night, E(r, n) is the expected value of the rth order statistic from a sample of size n, Φ is the CDF of a standard normal, and dn = 2 E(n, n).

We can implement Blom’s approximation with the following Mathematica code.

    PhiInv[x_] := Sqrt[2] InverseErf[2 x - 1]
    alpha = 0.375
    Blom[n_] := -2 PhiInv[(1 - alpha)/(n - 2 alpha + 1)]

If we plot dn and Blom’s approximation on the same plot, we won’t be able to tell them apart: the dots overlap. We can plot the difference between the two values with

    ListPlot[Table[d[n] - Blom[n], {n, 1, 100}]]

and get the following graph.

There have been more accurate approximations developed since 1958, but that’s as far as I want to go down this rabbit hole for now.

Update: I just noticed a comment on the first post in this series. Ashley Kanter’s approximation was supposed to be

3 (log10 n) 0.75

and not

3 log10 (n0.75)

The former is quite good, with a an error comparable to Blom’s method. Here’s a plot of the error:

 

[1] Gunnar Blom (1958). Statistical Estimates and Transformed Beta-Variables. John Wiley and Sons Inc.

Q codes in Seveneves

The first time I heard of Q codes was when reading the novel Seveneves by Neal Stephenson. These are three-letter abbreviations using in Morse code that all begin with Q.

Since Q is always followed by U in native English words, Q can be used to begin a sort of escape sequence [1].

There are dozens of Q codes used in amateur radio [2], and more used in other contexts, but there are only 10 Q codes used in Seveneves [3]. All begin with Q, followed by R, S, or T.

Tree[Q, {Tree[R, {A, K, N, S, T}], Tree[S, {B, L, O}], Tree[T, {H, X}]}]

Each Q code can be used both as a question and as an answer or statement. For example, QRS can mean “Would you like me to slow down” or “Please slow down.” I’ll just give the interrogative forms below.

Here are the 10 codes that appear in Stephenson’s novel.

QRA
What is your call sign?
QRK
Is my signal intelligible?
QRN
Is static a problem?
QRS
Should I slow down?
QRT
Should I stop sending?
QSB
Is my signal fading?
QSL
Are you still there?
QSO
Could you communicate with …?
QTH
Where are you?
QTX
Will you keep your station open for talking with me?

Related posts

[1] Some Q codes have a U as the second letter. I don’t know why—there are plenty of unused TLAs that begin with Q—but it is what it is.

[2] You can find a list here.

[3] There is one non-standard code in the novel: QET for “not on planet Earth.”

Missing Morse codes

Morse codes for Latin letters are sequences of between one and four symbols, where each symbol is a dot or a dash. There are 2 possible sequences with one symbol, 4 with two symbols, 8 with three symbols, and 16 with four symbols. This makes a total of 30 sequences with up to four symbols. There are 26 letters, so what are the four missing codes?

Here they are:

    .-.- 
    ..-- 
    ---. 
    ---- 

There are various uses for these codes, such as variants of Latin letters.

The first sequence on the list, .-.- is similar to two A’s .- .- and is used for variations on A, such as ä or æ.

The sequence ..-- is like a U (..-) with an extra dash on the end, and is used for variations on U, like ü.

The sequence ---. is like O (---) with an extra dot on the end, and is used for variations on O, like ö.

The last sequence ---- is used for letters like Ch or Š. Go figure.

Sequences of length 5

Sequences of five or six symbols are used for numbers, punctuation, and a few miscellaneous tasks, but there are a few unused combinations. (“Unused” is fuzzy here. Maybe some people do or did use these sequences.)

Here are the five-symbol sequences that do not appear in the Wikipedia article on Morse code:

    ..-.-
    .-.--
    -..--
    -.-.-
    -.---
    ---.-

So our of 32 possibilities, people have found uses for 26 of them.

Sequences of length 6

Out of 64 possible sequences of six symbols, 13 have found a use.

It’s harder to distinguish longer sequences by ear, and so it’s not surprising that most sequences of six symbols are unused; the ones that are used have special patterns that are easier to hear. Here are the ones that are used.

    ..--..
    ..--.-
    .-..-.
    .-.-.-
    .--.-.
    .----.
    -....-
    -.-.-.
    -.-.--
    -.--.-
    --..-.
    --..--
    ---...

Related posts