See, the mean we’re familiar with is more properly called the “arithmetic mean,” so called because it uses simple arithmetic. But there are others that show up in statistics and other scientific applications. The most common are the *geometric mean*, the *harmonic mean*, and the *quadratic mean* (also often called the *root mean square*). And all of these are based on the *generalized f-mean*.

A note before we start: in all of these examples, I’m going to use the data set **{7, 9, 29, 40, 42, 42, 65,
70, 87, 89}**, which has an arithmetic mean of 48.

The harmonic mean is actually pretty simple: it’s the inverse of the average of the inverses of your data. In mathematical notation, that’s

So let’s do an example. The first thing you do is find the inverse () of each item; in decimal that’s **{0.011, 0.011, 0.014, 0.015, 0.024, 0.024, 0.025, 0.034, 0.111, 0.143}**. Now we find the mean () of these inverses. The sum of these is 0.412, and divided by 10 gives us . Now all we have to do is find the inverse , which is 24.186*.

The quadratic mean (or root mean square) is likewise fairly simple; the only difference is that you square rather than inversing the data, and square root the resulting average. So in mathematical notation, that’s

Example time again. First we square each of the items, which gives us **{49, 81, 481, 1600, 1764, 1764, 4225, 4900, 7569, 7921}**. Summing gives us 30354, and dividing by 10 gives us . Now we find the square root of that to give us 55.42.

The geometric mean is somewhat more difficult to calculate, but it’s probably my favorite. In middle school I independently “invented” it while I was bored in math class, but pretty quickly gave it up because it turned out to be too unwieldy to calculate.

Now, if you’re familiar with arithmetic, quadratic, and geometric growth (which you should be) you might be able to guess what the geometric mean is. If not, here’s a hint:

If you guessed that calculating the geometric mean involves multiplying your data together, you’re correct and win a prize**!

The mathematical notation for the geometric mean involves a symbol there’s a good chance you haven’t seen (I know I hadn’t until I learned about geometric means): . That’s the product sign, and is essentially the equivalent of , except instead of adding the items together, you multiply them. So, the notation is:

So, we could calculate that as it is, by finding the product of our ten numbers (4,541,693,011,128,000, over 4½ quadrillion) and then the 10th root of that (36.789). Which is fine. But if we had any more numbers, my calculator would overflow, and sometimes you need to calculate the geometric mean of hundreds of numbers. To avoid having to use a computer with a googol bytes of memory, we take advantage of logarithms.

If you took pre-calculus with Mr. Kawamura, you might remember—will remember, considering how much he drilled it into our heads—that . What this means is that you can turn a product into a sum, which is a lot easier to deal with. So what we do is take the natural log*** of both sides of the equation, giving us

Which is a hell of a lot easier to calculate.

So let’s go back to our example data set. The natural logarithms of the items are **{1.946, 2.197, 3.367, 3.689, 3.738, 3.738, 4.174, 4.248, 4.466, 4.489}**. The sum of those is 36.052, which divided by 10 gives us . But that’s only the natural log of G, so now we have to reverse the logarithm by finding , which turns out to be 36.789.

By now it should be obvious that the means for this dataset are not the same. To review, we’ve got:

Mean Type |
Mean |

Arithmetic | 48 |

Harmonic | 24.186 |

Quadratic | 55.42 |

Geometric | 36.789 |

In other words, . And this is *always* true. (Unless all of your items are equal, in which case you wouldn’t bother calculating a mean, now would you?)

Now you may be seeing a pattern here. All of these different means follow basically the same form. This form is called the *generic f-mean*. It can be described thusly:

The only real restriction on this is that *f* be an invertible function. So you could go wild with this. You could use (for -½π < x < ½π). You could use . Hell, you could use .

I’m not really sure what to write in conclusion, other than “means are cool!” so I’ll just leave it here. In a while I’ll come back to this topic. Coming up Wednesday, though, is a post on sample sizes and why (some) psychologists are stupid.

*Incidentally, were you to do this by hand and round as I did to the thousandth place, the math doesn’t add up exactly because of rounding errors.

**1.0 cookies****, redeemable by mail!

***You can actually use any base you want for the logarithm, since we’ll be reversing it. I just use ln since I’m a biology geek and *e* turns up a lot more than 10.

****With a 95% margin of error of 2.0 cookies.

**Resources**

Random.org Where I got the example dataset.

Mean at Wikipedia

Statistics Calculators Includes calculators for all of the means (other than the generic f-mean) that I discussed here.

on WordPress How I did all the equations.

]]>Romney |
Obama |
Margin of Error |

45% | 55% | ±2% |

48% | 52% | ±3% |

50% | 50% | ±2% |

48% | 52% | ±4% |

46% | 54% | ±2% |

47% | 53% | ±1% |

59% | 41% | ±3% |

Would we conclude, based on the last poll, that there is a 95% chance of Romney having between 56% and 62% of the vote? Of course not. We conclude that the last poll was one of those 5% of polls that *do not* include the population mean in its confidence interval.

Another issue is that many pundits will say that, if two candidates are within the margin of error of each other, it’s a “statistical dead heat,” or, conversely, if the difference between the two candidates is more than the margin of error that there’s no question about the result. This is not necessarily wrong, in that it always ends up with an incorrect result, but it is wrong mathematically. If you want to know who will win you want to know the *difference* between the two candidates’ support, not their individual support. In statistics, this makes a big difference. If there are only two options (“Romney” and “Obama”), the margin of error of the difference is twice the margin of error of the votes. (So in our example above, there’s a whopping ±6% margin of error of the difference.) If there are more than two options (“Romney,” “Obama,” and “undecided”), the calculation is more complex, but it’s usually still very close to twice the margin of error of the votes. This means that when a poll reports Obama at 49% and Romney at 43% with a margin of error of ±3.5%, while you can be reasonably certain that Obama has between 45.5% and 52.5% of the vote and Romney has between 39.5% and 46.5% of the vote, you can’t be reasonable certain that Obama has more votes than Romney, since the difference between the two is less than the margin of error.

Finally, the margin of error doesn’t include all sources of error. It only includes *sampling error*, and any other sources of error can seriously mess with the poll. For example, pollsters’ models try to correct for things like the likeliness a given demographic will vote and the fact that some demographics are less likely to be included in polls (like those without land-line phones). If they get any of these guesses wrong, it introduces a source of error the margin of error doesn’t include. Similarly, if people lie to the pollsters (as they frequently do on issues such as race) or the pollsters asked a leading, framing, or misleading question (as they do basically all the time), the margin of error can’t describe the error that introduces.

What this all means is that polls are essentially useless. Given how evenly split the public is on most issues we’re interested in poll data for and the magnitude of the margins of error, plus the sources of error not included in margins of error, the chance of any given poll giving any sort of useful information is close to nil.

Before you lose all hope of predicting the winner of an election, however, consider this: if you pile a bunch of polls together you get a single poll with a much larger sample size, and thus a much smaller margin of error. By taking results of polls from multiple different pollsters, you also reduce the effect of individual polls’ and pollsters’ shortcomings. This is why FiveThirtyEight is so awesome, because that’s exactly what they do. Their predictions have been really accurate, for both federal and state elections. I can’t recommend them more.

Seriously, go check them out.

]]>It’s election season and that means that the news networks, newspapers, magazines, and blogs are awash with stories like this:

Mitt Romney leads President Obama by 3 percentage points in the deeply red state of Arizona, according to survey conducted by Public Policy Polling on behalf of Democratic think tank Project New America.

Romney leads 49 to 46 in Arizona, which is within the poll’s 3.5 percentage point margin of error. Arizona has only gone for the Democratic presidential candidate once since 1952.

So what does that mean?

As a biologist, I’ve never used the phrase “margin of error” before. I bet most of the scientists reading this haven’t either, because when we use summary statistics we’re generally interested in means, medians, confidence intervals, and standard deviations*. In fact, those are basically what’s taught in introductory statistics classes from high school to college. But if you’ve worked with statistics you’ve probably used a margin of error, even if you haven’t used “margin of error.”

Let’s take a step back. The fundamental problem of taking a poll is that barring a very strange accident of chance, you’re unlikely to get a sample that perfectly reflects your population. So for example, if you poll 100 people from a population of 100 million in which 46 million will vote for Mitt Romney and 54 million will vote for President Obama, it would be very odd indeed to find 46 Romney supporters and 54 Obama supporters. You’re more likely to get a sample of 48:52 or 43:57, or maybe even something like 51:49, just by chance. For the purposes of this example, I’m going to say we got a result where Romney trails Obama 47% to 53%.

So in order to reflect this chance we use measures of variance. In biology, standard error is usually the statistic of choice. In other fields of science, one might use the standard deviation of the mean, a confidence interval, or the raw variance statistic. For reasons I’ll expound on in a later post, I much prefer standard error, followed by confidence intervals.

A confidence interval (CI) is the range between which we can be reasonably certain that the true population mean (in our example above, 0.46 for Romney, 0.54 for Obama) falls. What we mean by “reasonably certain” varies. In physics, it’s not uncommon to say that anything less than 99.9% is not reasonably certain. Most sciences, and particularly the messy biological and social sciences, are a bit more forgiving of error and a standard of 95% is usual. So a 95% CI means that if we take 100 similar random samples, 95 of them will include the true population mean in their confidence interval.

In scientific papers, it’s common to report a CI. In the example above, our CI for Romney’s support is approximately 0.37–0.57. Since there’s no “undecided” or third party candidates in our example, any gain for Romney is a loss for Obama and vice versa, so the CI for Obama’s support is 0.43–0.53. In both cases, the CI is 0.20, or 20%, wide. (If we increased our sample size it would be much smaller.)

Reporting results this way can be clumsy, so pollsters report the results instead as a mean ± a margin of error. The margin of error is always one half the confidence interval, so in our example, pollsters would report that Obama leads Romney 53% to 47%, with a margin of error of ±10%.

And yes, for those of you who know how to calculate a confidence interval or standard error, it is that simple. It’s not some new summary statistic. It’s just a new name.

**Coming up:** some caveats you need to know about interpreting margins of error in polls.

*Sometime soon I’ll get a post up about these, since they’re important topics.

**Resources**

- Margin of Error at Wikipedia
- Margin of Error by Roger Niles
- Margin of Error at the TPM Political Dictionary
- Margin of Error at Wolfram Mathworld

No, I’m not going to tell you their names. I don’t post and tell.

Ahem. This one is different. Where my previous blogs suffered from being, shall we say, over-broad, this one is dedicated to statistics and data. My goal is to help demystify statistics for laypeople and show how data—and, of course, statistics—can be used to reveal truths or, well, lie. Sometimes damnedly.

First *real* post is coming up soon.