Theory and practice

Nice line from Erik Meijer via Twitter:

Happiness is when you drill a tunnel from two completely different sides (theory <–> practice) and then they line up *exactly*.

Posted in Uncategorized

Where combinator names come from

Today I found out where the one-letter names of some functions in combinatory logic come from. I’d seen these before (for example, in To Mock a Mockingbird) but I had no idea what inspired the names.

These functions — I, K, S, T, and Z — are known as the Schönfinkel combinators, and their names are somewhat mnemonic in German. (Only somewhat. Don’t get your hopes up.)

Definition Name Name origin
λx. x I Identitätsfunktion (identity function)
λx,y. x K Konstanzfunktion (constant function)
λx,y,z. xz(yz) S Verschmelzungsfunktion (amalgamation function)
λx,y,z. xzy T Vertauschungsfunktion (exchange function)
λx,y,z. x(yz) Z Zusammensetzungsfunktion (composition function)

Source: Practical Foundations of Mathematics, footnote on page 89. Available online here.

If you’re not familiar with the notation in the function definitions, see this introduction to lambda calculus.

Tagged with:
Posted in Computing

What good is an old weather forecast?

Why would anyone care about what the weather was predicted to be once you know what the weather actually was? Because people make decisions based in part on weather predictions, not just weather. Eric Floehr of ForecastWatch told me that people are starting to realize this and are increasingly interested in his historical prediction data.

This morning I thought about what Eric said when I saw a little snow. Last Tuesday was predicted to see ice and schools all over the Houston area closed. As it turned out, there was only a tiny amount of ice and the streets were clear. This morning there actually is snow and ice in the area, though not much, and the schools are all open. (There’s snow out in Cypress where I live, but I don’t think there is in Houston proper.)

Aftermath of last Tuesday’s storm

Related posts:

Interview with Eric Floehr
Accuracy versus perceived accuracy
History of weather prediction

Posted in Statistics

Time and Productivity

Contractors were working on my house all last week. I needed to be home to let them in, to answer questions, etc., but the noise and interruptions meant that home wasn’t a good place for me to work. In addition, my Internet connection was out for most of the week and I had a hard disk failure.

Looking back on the week, my first thought was that the week had been an almost total loss, neither productive nor relaxing. But that’s not right. The work I did do made a difference, reinforcing my belief that effort and results are only weakly correlated. (See Weinberg’s law of twins.)

Sometimes you have a burst of insight or creativity, accomplishing more in a few minutes than in an ordinary day. But that didn’t happen last week.

Sometimes your efforts are unusually successful, either because of the preparation of previous work or for unknown reasons. That did happen last week.

Sometimes you simply work on more important tasks out of necessity. Having less time to work gives focus and keeps work from expanding to fill the time allowed. That also happened last week.

***

I did get out of the house last Tuesday and wrote about it in my previous post on quality over quantity. This turned out to the theme of the week.

Tagged with:
Posted in Business

Quality over quantity

Whatever is true, whatever is honorable, whatever is just, whatever is pure, whatever is lovely, whatever is commendable, if there is any excellence, if there is anything worthy of praise, think about these things.” — Philippians 4:8

Ninety percent of everything is crud.” — Theodore Sturgeon [1]

 

I often think about quality and quantity. It’s so easy, particularly in America, to get sucked into substituting quantity for quality. For example, it’s how we eat. Striving for quality over quantity sounds good, but it’s not easy. It helps to have periodic reminders to go against the stream and pursue quality. Yesterday I got such a reminder at Edward Tufte’s one-day course in Houston.

The course emphasizes eliminating frills and administrative debris to make room for high quality displays of information. The course teaches and demonstrates a commitment to quality. At one point Tufte spoke more generally and more personally about pursuing quality over quantity.

He said most papers are not worth reading and that he learned early on to concentrate on the great papers, maybe one in 500, that are worth reading and rereading rather than trying to “keep up with the literature.” He also explained how over time he has concentrated more on showcasing excellent work than on criticizing bad work. You can see this in the progression from his first book to his latest. (Criticizing bad work is important too, but you’ll have to read his early books to find more of that. He won’t spend as much time talking about it in his course.) That reminded me of Jesse Robbins’ line: “Don’t fight stupid. You are better than that. Make more awesome.”

***

[1] Sturgeon’s law is usually stated as “Ninety percent of everything is crap,” though that’s not what he said. The original quip was “Sure, 90% of science fiction is crud. That’s because 90% of everything is crud.”

Posted in Uncategorized

Photos from Santa Barbara and Seattle

I was in southern California a couple weeks ago to help teach a class in Azure for researchers in Santa Barbara and to visit a client in Thousand Oaks. This week I was in Seattle to give a talk at Amazon. Here are some photos from my trips.

Sunrise at Isle Vista

View from UCSB

Reflection of the Space Needle in the EMP museum

 

Posted in Uncategorized

Probability is subtle

When I was in college, I overheard two senior faculty arguing over an undergraduate probability homework assignment. This seemed very strange. It occurred to me that I’d never seen faculty argue over something elementary before, and I couldn’t imagine an argument over, say, a calculus homework problem. Professors might forget how to do a calculus problem, or make a mistake in a calculation, but you wouldn’t see two professors defending incompatible solutions.

Intuitive discussions of probability are very likely to be wrong. Experts know this. They’ll say things like “I imagine the answer is around this, but I’d have to go through the calculations to be sure.” Probability is not like physics where you can usually get within an order of magnitude of a correct answer without formal calculation. Probabilistic intuition doesn’t take you as far as physical intuition.

Tagged with:
Posted in Uncategorized

Giving away classic probability book

I was culling out books, mostly obsolete technical books, and I remembered that I have an extra copy of Feller’s classic probability text. It’s volume 1, second edition. If you’re a student and would like the book, please send me an email with your mailing address.

Update: The book was claimed 11 minutes after this post was published.

Tagged with: ,
Posted in Uncategorized

What key has 30 sharps?

Musical keys typically have 0 to 7 sharps or flats, but we can imagine adding any number of sharps or flats.

When you go up a fifth (seven half steps) you add a sharp. For example, the key of C has no sharps or flats, G has one sharp, D has two, etc. Starting from C and adding 30 sharps means going up 30*7 half-steps. Musical notes operate modulo 12 since there are 12 half-steps in an octave. 30*7 is congruent to 6 modulo 12, and six half-steps up from C is F#. So the key with 30 sharps would be the same pitches as F#.

But the key wouldn’t be called F#. It would be D quadruple sharp! I’ll explain below.

Sharps are added in the order F, C, G, D, A, E, B, and the name of key is a half step higher than the last sharp. For example, the key with three sharps is A, and the notes that are sharp are F#, C#, and G#.

In the key of C#, all seven notes are sharp. Now what happens if we add one more sharp? We start over and start adding more sharps in the same order. F was already sharp, and now it would be double sharp. So the key with eight sharps is G#. Everything is sharp except F, which is double sharp.

In a key with 28 sharps, we’ve cycled through F, C, G, D, A, E, and B four times. Everything is quadruple sharp. To add two more sharps, we sharpen F and C one more time, making them quintuple sharp. The note one half-step higher than C quintuple sharp is D quadruple sharp, which is enharmonic with F#.

You could repeat this exercise with flats. Going up a forth (five half-steps) adds a flat. Or you could think of a flat as a negative sharp.

Related posts:

Circle of fifths and number theory

Circle of fifths and roots of 2
How to convert frequency to pitch

Tagged with:
Posted in Music

Braille, Unicode, and Binary

Braille characters live in a 4×2 matrix. This means there are eight positions where the surface is either flat or raised. You can naturally denote a Braille character by an 8-bit binary number: the bit for a single position is either 0 for flat and 1 for raised.

This is how Braille characters are encoded in Unicode. Braille characters are U+2800 through U+28FF, 2800 plus the binary number corresponding to the pattern of dots. However, there’s one surprise: the dots are numbered irregularly as indicated below:

1 4
2 5
3 6
7 8

Historically Braille had six cells, a 3×2 matrix, and the numbering made more sense: consecutive numbers, by column, left to right, the way Fortran stores matrices:

1 4
2 5
3 6

But when Braille was extended to a 4×2 matrix, the new positions were labeled 7 and 8 so as not to rename the previous positions.

The numbered positions above correspond to the last eight bits of the Unicode character, from right to left. That is, position 1 determines the least significant bit and position 8 determines the 8th bit from the end.

For example, here is Unicode character U+288A:

Braille character U+288A

The dots that are filled in correspond to positions 2, 4, and 8, so the last eight bits of the Unicode value are 10001010. The hexadecimal form of 10001010 is 8A, and the Unicode character is U+288A.

Posted in Uncategorized

Core memory

Here’s something I saw framed on a client’s wall today. The plaque reads

IBM 360 MODEL 25
CORE MEMORY
CIRCA 1968
2K BYTES

core memory

Here’s a close-up that shows the cores, little ring magnets at the intersection of wires.

close-up of cores

Related post: The weight of code

Posted in Computing

Heterogeneous data

I have a quibble with the following paragraph from Introducing Windows Azure for IT Professionals:

The problem with big data is that it’s difficult to analyze it when the data is stored in many different ways. How do you analyze data that is distributed across relational database management systems (RDBMS), XML flat-file databases, text-based log files, and binary format storage systems?

If data are in disparate file formats, that’s a pain. And from an IT perspective that may be as far as the difficulty goes. But why would data be in multiple formats? Because it’s different kinds of data! That’s the bigger difficulty.

It’s conceivable, for example, that a scientific study would collect the exact same kinds of data at two locations, under as similar conditions as possible, but one site put their data in a relational database and the other put it in XML files. More likely the differences go deeper. Maybe you have lab results for patients stored in a relational database and their phone records stored in flat files. How do you meaningfully combine lab results and phone records in a single analysis? That’s a much harder problem than converting storage formats.

 

Posted in Statistics

A year of consulting

I’ve been out on my own for about a year now, and it’s been a blast. If you’ve read this blog for a while you won’t be surprised to hear that I’ve been working in math, software development, and especially the overlap of the two.

As far as areas of math, I did more probability modeling than anything else. Also some work with time series, differential equations, networks, and to my surprise, a little category theory. As for software, I mostly worked in Python, R, and C++, writing code for data analysis and numerical algorithms.

People often ask what industry I work with, but my work cuts across industries. Last year I worked for a couple pharmaceuticals, a couple software companies, a search engine, etc. The most unexpected clients I had were a game developer and a wallet manufacturer.

I did a lot of small projects last year, especially when I was first getting started. It’s hard to live off small projects, but they’re fun. Micro-consulting on retainer is better. You get the variety and sense of accomplishment of small projects, but with more steady income. I have larger projects now, but I plan to keep squeezing in a few smaller projects as well as micro-consulting.

It looks like this year will be busier than last. I have a lot more lined up than I did this time last year. I expect to do the same kind of work I did last year. I expect to branch out a little as well, though it’s too early to say much about that.

I also expect to travel more this year as well. I’ll be in Santa Barbara and Los Angeles this week and Seattle later this month. In March I’m going to The Netherlands. If you’re in one of these areas and want to get together, please let me know.

 

Posted in Business

Whether to delegate

You shouldn’t necessarily do things that you’re good at. In economics, this idea is known as comparative advantage. Delegating may free up your time to do something more profitable. It might be to a country’s advantage to import something that they could produce cheaper domestically. Importing one thing might free up resources to export another thing that’s more valuable.

Comparative advantage is often illustrated by a hypothetical lawyer and an assistant. A lawyer who can type very quickly is still better off hiring someone else to do the typing because he can make much more per hour practicing law. If he could type twice as fast as an assistant, and he could earn more than twice as much practicing law as it costs to hire an assistant, he makes money by delegating.

This illustration makes sense at one level, but it also sounds a little quaint. In fact lawyers do quite a bit of typing. That’s explained by another economic idea: transaction costs. It costs time to recruit and hire an assistant. And once you have an assistant, it takes time to explain what you want done, time to wait for the work to come back, time to review the work, etc.

Highly paid executives type their own emails, at least some of the time, because it’s not worth the transaction costs to have someone else do it. But for a larger task, say typing up hundreds of handwritten pages, it’s worth paying the transaction costs to get someone else to do the typing.

Most advice on delegation is simplistic. It ignores transaction costs, and has a naive view of opportunity costs. It says that if you make $50 an hour, you should delegate anything you can hire done for $40 an hour since the opportunity cost of doing the $40 an hour task rather than delegating it is $10 an hour. But things are more subtle than that.

Opportunity costs only apply if you’re turning down an opportunity. If you stop doing $50 an hour work to do $40 an hour work, then you’re losing $10 an hour compared to what you could earn (ignoring the transaction costs of delegating). But if you don’t have $50 an hour work to do, if you’re otherwise idle, then delegating $40 an hour work is costing you $40 an hour, not saving you $10 per hour.

People are not machines. If you have an idle machine, give it work to do. And if two machines could do the same work, use the one that can do the work the cheapest. But people are more complicated. We like some kinds of work better than others, we learn, and we need time to rest.

Suppose you enjoy doing work that you could delegate for $40 an hour. You find it refreshing. There’s no opportunity cost in doing it yourself if the time to do it comes out of time you would have spent on a hobby.

Suppose you don’t enjoy doing work that you could delegate, but there’s something you could learn from doing it. In that case, there may be an opportunity benefit as well as an opportunity cost: learning something new may create opportunities in the future.

The previous two paragraphs account for enjoyment and learning, but not rest. If you don’t have $50 an hour work to do, doing $40 an hour work is only one alternative. Another alternative is to do nothing, which is very valuable in ways that are hard to quantify. And even work you enjoy may take energy away from other work.

Managing energy is more important than managing time. Energy is what gets things done, and time is only a crude surrogate for energy. Instead of only looking at what you could earn per hour versus what you could hire someone else for per hour, consider the energy it would take you to do something versus the energy it would free to delegate it.

If something saps your energy and puts you in a bad mood, delegate it even if you have to pay someone more to do it than it would cost you do to yourself. And if something gives you energy, maybe you should do it yourself even if someone else could do it cheaper.

Finally, note that energy isn’t the same as pleasure, though they often go hand in hand. Some activities are enjoyable but draining, and some are not enjoyable but invigorating. For example, I enjoy teaching, but it takes a lot out of me. And most people don’t enjoy exercise that much even though it gives them energy.

Posted in Business

Hum-drum fairy tales

The subtitle of That Hideous Strength is “A Modern Fairy-Tale for Grown-Ups.” C. S. Lewis explains in the preface why the book begins with mundane scenes even though he calls it a fairy tale.

If you ask why—intending to write about magicians, devils, pantomime animals, and planetary angels—I nevertheless begin with such hum-drum scenes and persons, I reply that I am following the traditional fairy-tale. We do not always notice its method, because the cottages, castles, woodcutters, and petty kings with which a fairy-tale opens have become for us as remote as the witches and ogres to which it proceeds. But they were not remote at all to the men who made and first enjoyed the stories.

Tagged with:
Posted in Uncategorized