Economics in one sentence

From Economics in One Lesson:

… the whole of economics can be reduced to a single lesson, and that lesson can be reduced to a single sentence. The art of economics consists in looking not merely at the immediate but at the longer effects of any act or policy; it consists in tracing the consequences of that policy not merely for one group but for all groups.

Related post: One thing to remember in economics

Deleting the Windows recycle bin desktop icon

I’ve never kept many icons on my desktop, and tonight I decided to reduce the number to zero. Deleting the recycle bin icon took a little research.

Windows Vista will let you simply delete the recycle bin but other versions of Windows will not.

On Windows 7 you can right-click on the desktop, select Personalize -> Change desktop icons, and uncheck the box for the recycle bin.

On Windows XP, you can edit the registry as described here. The registry changes will take effect next time you log in. [Update: unfortunately the link is no longer available.]

If you don’t want to edit your XP registry, you can right-click on the desktop, select the Arrange Icons By menu, and uncheck the Show Desktop Icons menu. However, this will hide all icons, not just the recycle bin, and will not let you see anything you drag to the desktop until you re-check Show Desktop Icons.

If you miss the recycle bin icon, it’s still in the file explorer on the left side.

Related post: Using Windows without a mouse

Odd perfect numbers

Yesterday I wrote about even perfect numbers. What about odd perfect numbers? Well, there may not be any.

I couldn’t care less about perfect numbers, even or odd. But I find the history and the mathematics surrounding the study of perfect numbers interesting.

As soon as you define perfect numbers and start looking for examples, you soon realize that all your examples are even. So people have wondered about the existence of odd perfect numbers for at least 2300 years.

No one has proved that odd perfect numbers do or do not exist. But people have proved properties that odd perfect number must have, if there are any.  So far, although the requirements for odd perfect numbers have become more demanding, they are not contradictory and it remains logically possible that such numbers exist. However, most experts believe odd perfect numbers probably don’t exist. (Either odd perfect numbers exist or they don’t. How can one say they “probably” don’t exist? See an explanation here.)

Wikipedia lists properties that odd perfect numbers must have. For example, an odd perfect number must have at least 300 digits. It’s interesting to think how someone determined that. In principle, you could just start at 1 and test odd numbers to see whether they’re perfect. But in practice, you just won’t get very far.

A year is about 10^7.5 seconds (see here). If you had started testing a billion (10^9) numbers a second since the time of Euclid (roughly 10^3.5 years ago) you could have tested about 10^20 numbers by now. Clearly whoever came up with the requirement N > 10^300 didn’t simply use brute force. There may have been some computer calculation involved, but if so it had a sophisticated starting point.

Related: Applied number theory

Even perfect numbers

I just got a review copy of Maths 1001 by Richard Elwes. As the title may suggest, the book is a collection 1001 little math articles. (Or “maths articles” as the author would say since he’s English.) Most of the articles are elementary though some are an introduction to advanced topics. Here’s something I learned from an article that was somewhere in the middle, the connection between perfect numbers and Mersenne primes.

Euclid (fl. 300 BC) proved that if M is a Mersenne prime then M(M+1)/2 is perfect. (A number is “perfect” if it equals the sum of its divisors less than itself. For example, 6 = 1 + 2 + 3 and 28 = 1 + 2 + 4 + 7 + 14. A Mersenne prime is a prime of the form 2n – 1.) Euclid didn’t use the term “Mersenne prime” because Mersenne would come along nearly two millennia later, but that’s how we’d state Euclid’s result in modern terminology.

The converse of Euclid’s result is also true. If N is an even perfect number, then N = M(M+1)/2 where M is a Mersenne prime. Ibn Al-Haytham conjectured this result in the 10th century but it was first proved by Leonard Euler in the 18th century. (What about odd perfect numbers? See the next post.)

I’ve enjoyed reading Maths 1001. I’ll flip through a few pages thinking the material is all familiar but then something like the story above will stand out.

Update: Richard Elwes informs me that his book is published under the title Mathematics 1001 in the US. My review copy was a British edition.

Related: Applied number theory

Blasted through a riverbed

In 1916, Marshall Mabey was working on a subway tunnel under New York’s East River. Compressed air was pumped into the tunnel to keep the soft earth between the river and the tunnel from caving in. A crack formed in the tunnel ceiling and Mabey was blown through the crack, through the river, and 25 feet into the air. He fell back into the river and was rescued. He survived unscathed and said he planned to go right back to work. The original New York Times account of the blow out is available here.

Marshall Mabey’s story is amazing. But I also found his wife’s reaction remarkable even though I imagine it was unremarkable at the time.

Of course I know that Marshall is in danger every time he goes to work but all work is dangerous and my husband is as careful as he can be. His job is a good one and I am glad he has it.

Object oriented vs. functional programming

From Michael Feathers:

OO makes code understandable by encapsulating moving parts.
FP makes code understandable by minimizing moving parts.

This explains some of the tension between object oriented programming and functional programming. The former tries to control state behind object interfaces. The latter tries to minimize state by using pure functions as much as possible.

It’s understandable that programmers accustomed to object oriented programming would like to add functional programming on top of OO, but I believe you have to make more of an exclusive commitment to functional programming to get the most benefit. For example, pure functions are easier to debug and to execute in parallel due to their lack of side effects. But if your code is only semi-functional, you can’t have the same confidence in testing your code or in spreading it across processors.

James Hague argues that 100% functional purity is impractical and that one should aim for 85% purity. But the 15% impurity needs to be partitioned, not randomly scattered across your code base. A simple strategy for doing this is to use functional in the small and OO in the large. Clojure also has some very interesting ideas for isolating the stateful parts of a program.

Related post: Pure functions have side effects

Mathematically correct but psychologically wrong

The snowball strategy says to pay off your smallest debt first, then the next smallest, and so on until you’re out of debt.

When I first heard of this I thought it was silly. Clearly the optimal strategy is to pay off the debt with the highest interest rate first. That assessment is mathematically correct, but psychologically wrong. The snowball strategy provides a sense of accomplishment and encouragement by reducing the number of debts as soon as possible. Ideally someone would be able to pay off at least one debt before their determination to get out of debt wanes.

My point here isn’t to give financial advice. I bring up the snowball strategy because it is an example of a problem with an obvious but naive solution. If someone is overwhelmed by debt, they need encouragement more than a mathematically optimal strategy. However, the snowball strategy may not be psychologically optimal for everyone. This further illustrates the idea that optimal real-life strategies are more complicated than mathematical models.

Many things that don’t look optimal are in fact optimal once you take the necessary constraints into account. For example, software that seems poorly designed may in fact have been brilliantly designed when you consider its economic and historical constraints. (This may even be the norm. Nobody complains about how badly obscure software was designed. We complain about software that has been successful enough to criticize.)

Related posts

Sledgehammer technique for trig integrals

There’s a powerful integration trick that I don’t believe is too widely known. Some calculus books mention it in a footnote, but few emphasize it. This is unfortunate since this trick applies to more problems than many of the more ad hoc techniques that are commonly taught.

Karl Weierstrass (1815-1897) came up with the idea of using t = tan(x/2) to convert trig functions of x to rational functions of t. If t = tan(x/2), then

  • sin(x) = 2t/(1 + t2)
  • cos(x) = (1 – t2) / (1 + t2)
  • dx = 2 dt/(1 + t2).

This means that any integral of a rational function of sines and cosines can be converted to an integral of rational function of t. And any rational function of t can be integrated in closed form by using partial fraction decomposition, though the partial fraction decomposition may need to be performed numerically.

I call this the sledgehammer technique because it’s overkill for the simplest trig integrals; other less general techniques are easier to apply in such problems. On the other hand, Weierstrass’ technique is very general and can evaluate integrals that look impossible at first glance.

More integration posts

Bias and consistency

Suppose you have two ways to estimate something you’re interested in. One is biased and one is unbiased. Surely the unbiased method is better, right? Not necessarily. Statistical bias is not as bad as it sounds.

Under ideal conditions, an unbiased estimator gives the correct answer on average, but each particular estimate may be ridiculous. Suppose you ask me to estimate how many dwarfs were in Snow White and the Seven Dwarfs. If I alternately guess 100 and -272, each guess will be wildly wrong. But if 75% of the time I guess 100 and 25% of the time guess -272, my average guess will be 7 and so my estimates will be unbiased. But if half the time I guess 8 and half the time I guess 7, my average guess will be 7.5 and my process will be biased. However, each estimate will be more accurate.

Consistency is a weaker condition than unbiasedness. Consistency says that if you feed your method enough data generated from your assumed model, your estimates will converge to the correct value.

But if your model is not exactly correct (and it never is) will you get a reasonably good result? It’s possible for an inconsistent method to provide good results in practice and it’s possible that a consistent method may not.

In his blog post on cross validation, Rob Hyndman mentions a paper that shows one validation method is consistent and another is not. Rob concludes

Frankly, I don’t consider this is a very important result as there is never a true model. In reality, every model is wrong, so consistency is not really an interesting property.

In the context of his post, Rob argues that the most important test of a statistical method is how well it predicts future data. Some people have commented that this comes down too hard on consistency. But we’re talking about a blog post, and blogs don’t use the same kind of carefully qualified language that formal papers do. Perhaps in a more formal setting Rob might argue that a gross failure of consistency gives one reason to suspect a method won’t predict well, but a lack of complete consistency shouldn’t remove a method from consideration. Such language may be inoffensive, but it lacks the verve of his original statement.

Too often bias and consistency are seen as all-or-nothing properties. In theoretical statistics, one typically asks whether a method is biased, not how biased it is. The same is true of consistency. Bias and consistency are only two criteria by which methods can be evaluated. A small amount of bias or inconsistency may be an acceptable trade-off in exchange for better performance by other criteria such as efficiency or robustness.

Related posts