I like science fiction as a genre, but I dislike most science fiction books I’ve tried. I start with books that come highly recommended and give up on most of them. But here are a few I’ve read and enjoyed.
This morning I had coffee and a generous slice of squash bread at Top Pot Doughnuts in Seattle. When I went to pick up my coffee I saw a large photo of President Obama ordering coffee at the same place.
This is the second time I’ve been at a shop that proudly remembered our president stopping by. The first was a diner in San Juan that I cannot remember the name of. They put a plaque on the table President Obama sat at. If Top Pot did too, I missed it.
I enjoyed a few minutes of quiet this morning, something President Obama certainly did not have a chance to do here. One wall of the shop is lined with old books, so naturally that’s where I sat. I pulled down a small book that bound the December 1942 issues of My Garden magazine.
I find the ads in old magazines interesting for what they say between the lines. The ads are more interesting than the articles, the opposite of contemporary magazines, though that depends on the magazine.
One thing that struck me was the small ratio of advertisement to content. I suppose the original subscribers didn’t notice this, or maybe thought the magazine was putting in too many ads. I imagine they would be shocked by magazines that squeeze articles in between the ads.
Another thing that struck me was the somber but hopeful tone of the ads. Ford had a series of ads entitled “Until then …”. The ads seemed to say “We know nobody is going to be buying a car any time soon. But some day this war will be over, and when it is, we hope you’ll remember us.” Other companies tried to make the best of rationing. For example, one ad for shaving cream said that it was a good thing that their product worked so well since there are limits on how much shaving cream you can buy.
It was a pleasant way to start the day, without Secret Service agents buzzing around and without rationing limits on things like coffee and squash bread.
The other day someone asked me to look at the search data for Debug Pest Control, a pest management company based in Rhode Island. One of the things I wanted to visualize was how the search terms overlapped with each other.
To do this, I created a graph where the nodes are the keywords and edges join nodes that share a word. (A “keyword” is actually a set of words, whatever someone types into a search.) The result was a solid gray blob be cause the the nodes are so densely connected.
I thinned the graph by first only looking at keywords that have occurred at least twice. Then I made my connection criteria a little stronger. I take the union of the individual words in two keywords and create a connection if at least 1/3 of these words appear in both keywords.
(You can click on the image to see a larger version.)
The area of each red dot is proportional to the number of times someone has come to the site using that keyword. You can see that there’s long-tail behavior: while some dots are much larger than others, there are a lot of little dots.
In case you’re curious, these are the top keywords:
- pest control
- pest control ri
- pest control rhode island,
- plants that keep bees away
- poisonous snakes in ri
- plants that keep bees and wasps away
- plants to keep bees away
- plants that keep wasps away
- pest control companies
The keywords were filtered a little before making the graph. Some of the top keywords contained “debug.” These may have been people using the term to refer to eliminating pests from their property, but more likely they were people who knew the company name. By removing “debug” from each of the keywords, the results focus on people searching for the company’s services rather than the company itself.
A statistician could help a lawyer answer the following questions.
- Was this data collected in a proper way?
- Does common sense apply here, or is there something subtle going on?
- What conclusions can we draw from the data?
- Is this analysis routine or is there something unusual about it?
- How much confidence can we place in the conclusions?
- How can you explain this to a jury?
- Did opposing counsel analyze their data properly?
The discrete Fourier transform (DFT) of length N multiplies a vector by a matrix whose (j, k) entry is ωjk where ω = exp(-2πi/N), with j and k running from 0 to N – 1. Each element of the matrix is a rotation, so if N = 12, we can represent each element by an hour on a clock. The angle between the hour hand and minute hand corresponds to the phase of the matrix entry. We could also view each element as a color around a color wheel. The image below does both.
The matrix representing the inverse of the DFT is the conjugate of the DFT matrix (divided by Nf, but we’re only looking at phase here, so we can ignore this rescaling.) The image below displays the DFT matrix on the left and it’s inverse on the right.
Taking the conjugate amounts to making all the clocks run backward.
The DFT is often called the FFT. Strictly speaking, the FFT is an algorithm for computing the DFT. Nobody computes a DFT by multiplying by the DFT matrix, because the FFT is faster. The DFT matrix has a lot of special structure, which the FFT takes advantage of to compute the product faster than using ordinary matrix multiplication.
By the way, there are Unicode characters for clock times on the hour, U+1F550 through U+1F55B. I created the image above by writing a script that put the right characters in a table. The colors have HSL values where H is proportional to the angle and S = L =0.8.
2016 appears in π starting at the 7173rd decimal place:
You can confirm this with Mathematica or Wolfram Alpha:
Mod[ Floor[10^7177 pi] , 10000]
I found it using the following Python code:
>>> from sympy import pi >>> digits = str(pi.evalf(10000))[2:] >>> digits.find('2016') 7173
By the way, it’s also true that 2016 = 1 + 2 + 3 + … + 63.
Here are this blog’s most popular technology posts of 2015:
And here are the most popular math posts of 2015:
Automation doesn’t always save as much time or effort as we expect.
The xkcd cartoon above is looking at automation as an investment. Does the work I put in now eventually save more work than I put into it? Automation may be well worth it even if the answer is “no.”
Automation can be like a battery as well as an investment. Putting energy into batteries is a bad investment; you’ll never get out as much energy as you put in. But that’s not why you put energy into batteries. You put energy in while you can so you can use some of that energy later when you need it.
Write automation scripts when you have the time, energy, and motivation to do so and when nothing else is more important. (Or nothing is more interesting, if you’re looking for a way to procrastinate without feeling too guilty. This is called “moral compensation.”) You may indeed save more work than you put into writing the scripts. But you also may save mental energy just when you need it.
Suppose it takes you an hour to write a script that only saves you two minutes later. If that two minutes would have derailed your concentration at a critical moment, but it didn’t because you had the script, writing the script may have paid for itself, even though you invested 60 minutes to save 2 minutes.
If your goal is to save mental energy, not time, you have a different strategy for automation. If a script executes faster than a manual process, but it takes a long time to remember where to find the script and how to run it, it may be a net loss. The less often you run a script, the chattier the interface should be.
The same considerations apply to learning third party software. I suspect the time I’ve put into learning some features of Emacs, for example, will not pay for itself in terms of time invested versus time saved. But I’ve invested leisure time to save time when I’m working hard, not to save keystrokes but to save mental energy for the project at hand.
Related post: How much does typing speed matter?
I’m making a couple changes to my Twitter accounts.
First, I’m winding down @PerlRegex. I’ll stop tweeting there when my scheduled tweets run out. I suggest that everyone who has been following @PerlRegex start following @RegexTip instead. The latter is more general, but is mostly compatible with Perl.
Second, I’m reviving my @DSP_Fact. I stopped tweeting there a couple years ago, but I’d like to start posting there again. This time it’s going to be a little broader. I intend to include some material on acoustics, Fourier analysis (continuous and discrete), and maybe some other related material.
I’ve expanded the data the page uses by merging in data from the STIX Project. More queries should return successfully now.
* * *
For daily tips on LaTeX and typography, follow @TeXtip on Twitter.
Richard Guy’s Strong Law of Small Numbers says
There aren’t enough small numbers to meet the many demands made of them.
In his article by the same name  Guy illustrates his law with several examples of patterns that hold for small numbers but eventually fail. One of these examples is
3! – 2! + 1! = 5
4! – 3! + 2! – 1! = 19
5! – 4! + 3! – 2! + 1! = 101
6! – 5! + 4! – 3! + 2! – 1! = 619
7! – 6! + 5! – 4! + 3! – 2! + 1! = 4421
8! – 7! + 6! – 5! + 4! – 3! + 2! – 1! = 35899
If we let f(n) be the alternating factorial sum starting with n, f(n) is prime for n = 3, 4, 5, 6, 7, 8, but not for n = 9. So the alternating sums aren’t all prime. Is f(n) usually prime? f(10) is, so maybe 9 is the odd one. Let’s write a code to find out.
from sympy import factorial, isprime def altfact(n): sign = 1 sum = 0 while n > 0: sum += sign*factorial(n) sign *= -1 n -= 1 return sum numprimes = 0 for i in range(3, 1000): if isprime( altfact(i) ): print(i) numprimes += 1 print(numprimes)
You could speed up this code by noticing that
altfact(n+1) = factorial(n+1) - altfact(n)
and tabulating the values of
altfact. The code above corresponds directly to the math, though it takes a little while to run.
So it turns out the alternating factorial sum is only prime for 15 values less than 1000. In addition to the values of n mentioned above, the other values are 15, 19, 41, 59, 61, 105, 160, and 601.
* * *
 The Strong Law of Small Numbers, Richard K. Guy, The American Mathematical Monthly, Vol. 95, No. 8 (Oct., 1988), pp. 697-712.
For daily tips on Python and scientific computing, follow @SciPyTip on Twitter.
Here are some of the non-technical books I’ve mentioned in blog posts this year. I posted the technical list a couple days ago.
Maybe I should say “less technical” rather than “non-technical.” For example, Surely You’re Joking, Mr. Feynman is a book about a physicist, but it’s at least as much a human interest book as a science book.
RSS lets you subscribe to blogs. It also lets you read posts in peace, free from distracting peripheral ads. This explains why Google would kill off the world’s most popular RSS reader.
Blogs used to display an icon linking to the site’s RSS feed, and any still do. Blogging software still creates RSS feeds, though links to these feeds have become harder to find.
There are several ways to find the RSS feed of a site that does not make this feed obvious.
- Your blog reader may be able to find the RSS from the site’s URL.
- You can try adding
/rssto the end of the domain.
- You may be able to find the RSS feed by looking at the HTML source of the front page.
- There are browser plug-ins that will show when a page has RSS feeds.
Take for example Bill Gates’ blog. You’ll see at the top how to subscribe by email, and you’ll see at the bottom links to Facebook, Twitter, LinkedIn, and YouTube, but no RSS.
Digg Reader was able to find the RSS feed from just the top level URL
Tacking /feed on the end doesn’t work, but
If you open up the page source, you’ll find 31 references to RSS. Turns out there is a link to the RSS feed after all. It’s in a menu under the + sign in the top right corner. While writing this, I started to change my example since I was wrong about the site not displaying an RSS link. But I decided to keep it because it shows that the steps above also work when there is an RSS link but you’ve overlooked it.
My RSS feeds
If you want to subscribe to this blog via RSS, there’s a big blue button on the right side that says Subscribe by RSS. You can also subscribe to individual categories of posts in case you’d like to subscribe to my math posts, for example, but not my software development posts, or vise versa.
There are also RSS feeds to my Twitter accounts, thanks to BazQux.
Here are some of the books I’ve mentioned in blog posts this year. One of these books may be just the present for a geek in your life.
This post looks at technical books: math, science, engineering, programming. I’ll have a follow-up post with non-technical books I’ve written about. (Update: here’s the non-technical list.)
|Book||Blog post mentioned in|
|The Art of Computer Programming||Deserted island books|
|Effective Computation in Physics||Interview: Anthony Scopatz and Katy Huff|
|Automate the Boring Stuff with Python||Rotating PDF pages|
Science and engineering
|Book||Blog post mentioned in|
|Strength of Materials||Basic equations of beam deflection|
|Gravitation||Deserted island books|
|The Interstellar Age: Inside the Forty-Year Voyager Mission||Key fobs and interstellar space|
The term white noise is fairly common. People unfamiliar with its technical meaning will describe some sort of background noise, like a fan, as white noise. Less common are terms like pink noise, red noise, etc.
The colors of noise are defined various ways, but they’re all based on an analogy between the power spectrum of the noisy signal and the spectrum of visible light. This post gives the motivations and intuitive definitions. I may give rigorous definitions in some future post.
White noise has a flat power spectrum, analogous to white light containing all other colors (frequencies) of light.
Pink noise has a power spectrum inversely proportional to its frequency f (or in some definitions, inversely proportional to fα for some exponent α near 1). Visible light with such a spectrum appears pink because there is more power toward the low (red) end of the spectrum, but a substantial amount of power at higher frequencies since the power drops off slowly.
The spectrum of red noise is more heavily weighted toward low frequencies, dropping off like 1/f2, analogous to light with more red and less white. Confusingly, red noise is also called Brown noise, not after the color brown but after the person Robert Brown, discoverer of Brownian motion.
Blue noise is the opposite of red, with power increasing in proportion to frequency, analogous to light with more power toward the high (blue) frequencies.
Grey noise is a sort of psychologically white noise. Instead of all frequencies having equal power, all frequencies have equal perceived power, with lower actual power in the middle and higher actual power on the high and low end.