Take chances, make mistakes, and get messy

From Magic School Bus:

Take chances, make mistakes, and get messy.

Magic School Bus is an educational television show for children. The quote above is often repeated by the main character of the show, Ms. Frizzle.

Too many programs that supposedly teach science only teach results from science. Magic School Bus does both. It teaches specific facts, such as the names of the planets, but it also teaches that science is about taking chances, making mistakes, and getting messy.

Related post: Preparing for innovation

How much does typing speed matter?

How important is it to be able to type quickly? Jeff Atwood has said numerous times that programmer must be a good typist. For example, a few weeks ago he said

I can’t take slow typists seriously as programmers. When was the last time you saw a hunt-and-peck pianist?

But programming is not like playing piano.  Programming is more like composing music than performing music. Most composers can play piano well, but some cannot.

What if you write prose rather than programs? In his book On Writing, Stephen King recommends writing 1000 words per day. If writing were only a matter of typing, how long would that take? Half an hour at a modest rate of 30 words per minute. Say you have to type 2000 words to keep 1000 due to corrections. Now we’re up to an hour. People who write for a living do not literally spend most of their time writing. They spend most of their time thinking.

Clearly it’s good to be able to type quickly. As I’ve argued here, the primary benefit of quick data entry is not the time saved in data entry per se, it’s the increased chance that your hands can keep up with your brain.

However, a slow typist can still be productive. Consider physicist Stephen Hawking. He is only able to communicate to the world via a computer, ALS having destroyed nearly all of his motor control. For years he controlled his computer via a switch he could toggle with his hand; he now uses a camera that detects blinks. He says he can type 15 words per minute. Still, he has managed to write a few things, 194 publications from 1965 to 2008. You may have seen some of his books.

Learning to type well is a good investment for those who are physically able to do so, but it’s not that important. Once you reach moderate proficiency, improving your speed will not improve your productivity much. If a novelist writing 1000 words per day were able to type infinitely fast, he or she could save maybe an hour per day.

You many not be able to increase your typing speed too much no matter how hard you try. According to Guinness Book of World Records, Barbara Blackburn was the world’s fastest English language typist. She could sustain 150 words per minute. That means she was only 10x faster than Stephen Hawking. Most of us are somewhere between Stephen Hawking and Barbara Blackburn. In other words, nearly everyone types at the same speed, within an order of magnitude.

Related posts:

Computing days of the week in your head

Years ago I taught a “math for poets” class. (I don’t remember the actual name of the course. Everyone called it “math for poets” because it was the one math class humanities majors had to take.) I taught the students how to mentally figure out days of the week and they loved it. It was easily the most popular topic in the course. It was satisfying to find any topic that was popular in a course that many had put off as long as possible.

I’d thought about turning my old class notes into a blog post, but there’s one minor complication. I taught this course in the 1990’s and the method was designed to make it easiest to work with dates in the 20th century. You could use it to compute days of the week in the 21st century, but doing so would take one more step than revising the method to make it easier to work with 21st century dates. I recently ran across an article that gives such an updated method.

Typesetting chemistry in LaTeX

Yesterday I gave the following tip on TeXtip:

Set chemical formulas with math Roman. Example: sulfate is $mathrm{SO_4^{2-}}$

TorbjoernT and scmbradley let me know there’s a better way: use Martin Hansel’s package mhchem. The package is simpler to use and it correctly handles subtle typographical details.

Using the mhchem package, sulfate would be written ce{SO4^2-}. In addition to chemical compounds, mhchem has support for bonds, arrows, and related chemical notation.

Example:

Source:

\documentclass{article}
\usepackage[version=3]{mhchem}
\parskip=0.1in
\begin{document}

\ce{SO4^2-}

\ce{^{227}_{90}Th+}

\ce{A\bond{-}B\bond{=}C\bond{#}D}

\ce{CO2 + C -> 2CO}

\ce{SO4^2- + Ba^2+ -> BaSO4 v}

\end{document}

 

For more information, see the mhchem package documentation.

Related posts:

Maybe you only need it because you have it

Some cities need traffic lights because they have traffic lights. If one traffic light goes out, it causes a traffic jam. But sometimes when all traffic lights go out, say due to a storm, traffic flows better than before.

Some buildings need air conditioning because they have air conditioning. Because they were designed to be air conditioned, they have no natural ventilation and would be miserable to inhabit without air conditioning.

Some people need to work because they work. A family may find that their second income is going entirely to expenses that would go away if one person stayed home.

It’s hard to tell when you’ve gotten into a situation where you need something because you have it. I had a friend that worked for a company that sold expensive software development tools. He said that one of the best perks of his job was that he could buy these tools at a deep discount. But he didn’t realize that without his job, he wouldn’t need these tools! He wasn’t using them to develop software. He was only using them so he could demonstrate and sell them.

It may be even harder for organizations to realize it has been caught in a cascade of needs. Suppose a useless project adds staff. These staff need to be managed, so they hire a manager. Then they hire people for IT, accounting, marketing, etc. Eventually they have their own building. This building needs security, maintenance, and housekeeping. No one questions the need for the security guard, but the guard would not have been necessary without the original useless project.

When something seems absolutely necessary, maybe it’s only necessary because of something else that isn’t necessary.

Related post: Defining minimalism

Military intelligence from serial numbers

During World War II, America and her allies needed to estimate the number of Panzer V tanks Germany had produced. The solution was simple: Look at the serial numbers of the captured tanks. If you assume the tanks had been sequentially numbered — as in fact they were — you could view the serial numbers of the captured tanks as random samples from the entire range. You could then use statistics to estimate the range and hence the number of tanks produced. More details available here.

A few years later America tried to use the serial number trick to estimate the number of Soviet strategic bombers. This time the trick backfired.

In 1958, American military intelligence believed the USSR would soon have four hundred Bison and three hundred Bear bombers capable of striking the American heartland. Their evidence was the high serial number of a Bison that had flown at a May Day parade in Moscow. In fact, the Soviets knew the Americans were watching, and intentionally inflated that number. — Rocket Men, page 118.

The Panzer estimate was accurate because the Allies had hundreds of data points, enough to support the assumption that the tanks were sequentially numbered and to make a good estimate of the total number.

The Bison bomber was only one data point, but it was consistent with what intelligence services (wrongly) believed. At that time, the US had grossly over-estimated the military capabilities of the USSR. According to Rocket Men, Khrushchev turned down US offers to cooperate in space exploration because he feared that such cooperation would give the US a more accurate assessment of his country’s military.

Related post: Selection bias and bombers

You can be a hero with a simple idea

Yesterday I mentioned someone who published a scholarly paper in 1994 for a technique commonly taught in freshman calculus. There’s been a lot of discussion of this (the paper, not my blog post) on the web. The general take has been that this was an egregious failure in the peer review system. No one recognized a simple, centuries-old idea. No one called up a high school math teacher and asked “Hey, have you seen this before?” All that is true, but here’s a different take on the situation.

The paper reinventing the trapezoid rule has been cited 75 times. It must have filled a need. Yes, the author was ignorant of basic calculus. But apparently a lot of other doctors are just as ignorant of calculus. The author did the medical profession a service by pointing out a simple way to estimate the area under a glucose-response curve. The technique was not original, and should not have been published as original research, but it was valuable.

Surely some doctors already knew how to find the area under a glucose-response curve. But apparently many others did not, and they learned something useful from the article. The article did some good, more good than original but arcane articles that no one reads, even though it was bad scholarship.

The author made a connection that not everyone else had made. This reminds me of Picasso’s sculpture Head of a Bull.

Picasso: Head of a Bull

All Picasso did was put handle bars on top of a bicycle seat and say “Hey, that looks like a bull.” His sculpture took zero technical skill, but it was clever. Was Picasso the first human to ever have this idea? Maybe, but I doubt it.

Sometimes you can be a hero by taking what is common as dirt in one context and applying it to a new context.

Related posts:

NASA did not find arsenic-based life

Headlines are saying today that NASA found microbes that use arsenic the way all other known life uses phosphorous. The NASA web site says NASA-Funded Research Discovers Life Built With Toxic Chemical. Some other headlines include “NASA finds ‘alien life’ made of arsenic,” “NASA finds arsenic-based life,” and “NASA finds arsenic-loving bacterium.” These headlines are misleading.

The phrase arsenic-based life is misleading because most people would assume this is in contrast to carbon-based life. No, the discovery involves substituting arsenic for phosphorous. So this new microbe is only arsenic-based in the sense that most life is phosphorous-based. Actually, even that is not correct. This is a phosphorous-based life form that has been tricked into using arsenic.

NASA did not find a microbe that substitutes arsenic for phosphorous. They coaxed a microbe into substituting arsenic for phosphorous. Here’s the relevant paragraph from NASA’s story:

The newly discovered microbe, strain GFAJ-1, is a member of a common group of bacteria, the Gammaproteobacteria. In the laboratory, the researchers successfully grew microbes from the lake on a diet that was very lean on phosphorus, but included generous helpings of arsenic. When researchers removed the phosphorus and replaced it with arsenic the microbes continued to grow. Subsequent analyses indicated that the arsenic was being used to produce the building blocks of new GFAJ-1 cells.

So it seems that NASA found a microbe that could use arsenic, not a microbe that naturally does use arsenic. Perhaps some are inferring that because NASA was able to make this happen in a lab, it may also have happened naturally, though no one has seen that. Maybe so.

NASA goes on to say

The key issue the researchers investigated was when the microbe was grown on arsenic did the arsenic actually became incorporated into the organisms’ vital biochemical machinery, such as DNA, proteins and the cell membranes.

This is an amazing discovery, but it’s not quite the discovery that headlines imply.

Update: More detailed criticism of the NASA announcement from Nature News. Experts challenge the claim that the microbes actually incorporate arsenic in organic compounds.

Three surprises with the trapezoid rule

The trapezoid rule is a very simple method for estimating integrals. The idea is to approximate the area under a curve by a bunch of thin trapezoids and add up the areas of the trapezoids as suggested in the image below.

This is an old idea, probably older than the formal definition of an integral. In general it gives a crude estimation of the integral. If the width of the trapezoids is h, the error in using the trapezoid rule is roughly proportional to h2. It’s easier to do better. For example, Simpson’s rule is a minor variation on the trapezoid rule that has error proportional to h5.

So if the trapezoid rule is old and inaccurate, why does anyone care about it? Here are the surprises.

  1. You can still get a publication out of the trapezoid rule! In 1994, a doctor published a paper reinventing the trapezoid rule. Not only did the editors not recognize this ancient algorithm, the paper has been cited many times since it was published. (Update: more about the trapezoid paper here.)
  2. Although the trapezoid rule is inefficient in general, it can be shockingly efficient for periodic functions.
  3. The trapezoid rule can also be shockingly efficient for analytic functions that go to zero quickly, so called double exponential functions.

The last two observations are more widely applicable than you might think at first. What if you want to integrate something that isn’t periodic and isn’t a double exponential function? You may be able to do a change of variables that makes your integrand have one of these special forms. The article Fast Numerical Integration explains an integration method based on double exponential functions and includes C++ source code.

The potential efficiency of the trapezoid rule illustrates a general principle: a crude method cleverly applied can beat a clever technique crudely applied. The simplest numerical integration technique, one commonly taught in freshman calculus, can be extraordinarily efficient when applied with skill to the right problem. Conversely, a more sophisticated integration technique such as Gauss quadrature can fail miserably when naively applied.

Related posts:

Static versus dynamic typing

Static versus typing is a Ford-Chevy argument among programmers. Here’s the best comment on the subject I’ve seen lately.

Very briefly put, the Haskell [strongly, statically typed] perspective emphasizes safety, while the dynamic outlook favors flexibility. If someone had already discovered one way of thinking about types that was always best, we imagine that everyone would know about it by now.

Source: Real World Haskell.

The second sentence applies equally well to all Ford-Chevy arguments: if one alternative were uniformly better than all others, word would get out. These arguments rage because they involve comparisons along multiple (often implicit) criteria and no alternative is simultaneously better by all criteria.

The relative advantages of programming languages depend on how the languages are used. Although dynamic languages place less emphasis on safety, programs written in dynamic languages may be safer in practice than this would imply. Also, in general it is easier to reason about code written in a statically typed language. However, a programmer can easily subvert strong static typing by writing stringly typed code. Code written in well in a dynamically typed  language will be easier to read than code written poorly in a statically typed language.

Comparisons of the advantages static and dynamic typing are nearly impossible. You could try to argue about what would happen “all other things being equal,” but of course all other things are never equal.

Related post: Questioning the Hawthorne effect