 • Print

Learn how to calculate the mean, median, and mode of your data in Excel 2016.

Save 35% off the list price* of the related book or multi-format eBook (EPUB + MOBI + PDF) with discount code ARTICLE.
* See informit.com/terms

This chapter is from the book

### This chapter is from the book 

In This Chapter

• Calculating the Mean
• Calculating the Median
• Calculating the Mode
• From Central Tendency to Variability

When you think about a group that’s measured on some numeric variable, you often start thinking about the group’s average value. On a scale of 1 to 10, how well do registered Independents think the president is doing? What is the average market value of a house in Minneapolis? What’s the most popular first name for boys born last year?

The answer to each of those questions, and questions like them, is usually expressed as an average, although the word average in everyday usage isn’t well defined, and you would go about figuring each average differently. For example, to investigate presidential approval, you might go to 100 Independent voters, ask them each for a rating from 1 to 10, add up all the ratings, and divide by 100. That’s one kind of average, and it’s more precisely termed the mean.

If you’re after the average cost of a house in Minneapolis, you probably ask some group such as a board of realtors. They’ll likely tell you what the median price is. The reason you’re less likely to get the mean price is that in real estate sales, there are always a few houses that sell for really outrageous amounts of money. Those few houses pull the mean up so far that it isn’t really representative of the price of a typical house in the region you’re interested in.

The median, on the other hand, is right on the 50th percentile for house prices; half the houses sold for less than the median price and half sold for more. (It’s a little more complicated than this, and I’ll cover the complexities shortly.) It isn’t affected by how far some home prices are from an average, just by how many are above an average. In that sort of situation, where the distribution of values isn’t symmetric, the median often gives you a much better sense of the average, typical value than does the mean.

And if you’re thinking of average as a measure of what’s most popular, you’re usually thinking in terms of a mode—the most frequently occurring value. For example, in 2015, Noah was the modal boy’s name among newborns.

Each of these measures—the mean, the median, and the mode—is legitimately if imprecisely thought of as an average. More precisely, each of them is a measure of central tendency: that is, how a group of people or things tend to cluster in some way around a central value.

## Calculating the Mean

When you’re reading, talking, or thinking about statistics and the word mean comes up, it refers to the total divided by the count. The total of the heights of everyone in your family divided by the number of people in your family. The total of the price per gallon of gasoline at all the gas stations in your city divided by the number of gas stations. The total number of a baseball player’s hits divided by the number of at bats.

In the context of statistics, it’s very convenient, and more precise, to use the word mean this way. It avoids the vagueness of the word average, which—as just discussed—can refer to the mean, to the median, or to the mode.

So it’s sort of a shame that Excel uses the function name AVERAGE() instead of MEAN(). Nevertheless, Figure 2.1 gives an example of how you get a mean using Excel.

Understanding the elements that Excel’s worksheet functions have in common with one another is important to using them properly, and of course, you can’t do good statistical analysis in Excel without using the statistical functions properly. There are more statistical worksheet functions in Excel, over 100, than any other function category. So I propose to spend some ink here on the elements of worksheet functions in general and statistical functions in particular. A good place to start is with the calculation of the mean, shown in Figure 2.1.

### Understanding Functions, Arguments, and Results

The function that’s depicted in Figure 2.1, AVERAGE(), is a typical example of statistical worksheet functions.

#### Defining a Worksheet Function

An Excel worksheet function—more briefly, a function—is just a formula that someone at Microsoft wrote to save you time, effort, and mistakes.

Suppose that Excel had no AVERAGE() function. In that case, to get the result shown in cell B13 of Figure 2.1, you would have to enter something like this in B13:

=(B2+B3+B4+B5+B6+B7+B8+B9+B10+B11) / 10

Or, if Excel had a SUM() and a COUNT() function but no AVERAGE(), you could use this:

=SUM(B2:B11)/COUNT(B2:B11)

But you don’t need to bother with those because Excel has an AVERAGE() function, and in this case you use it as follows:

=AVERAGE(B2:B11)

So—at least in the cases of Excel’s statistical, mathematical, and financial functions—all the term worksheet function means is a prewritten formula. The function results in a summary value that’s usually based on other, individual values.

#### Defining Arguments

More terminology: Those “other, individual values” are called arguments. That’s a highfalutin’ name for the values that you hand off to the function—or, put another way, that you plug into the prewritten formula. In the instance of the function

=AVERAGE(B2:B11)

the range of cells represented by B2:B11 is the function’s argument. The arguments always appear in parentheses following the function.

A single range of cells is regarded as one argument, even though the single range B2:B11 contains 10 values. AVERAGE(B2:B11,C2:C11) contains two arguments: one range of 10 values in column B and one range of 10 values in column C. (Excel has a few functions, such as PI(), that take no arguments, but you have to supply the parentheses anyway.)

Many statistical and mathematical functions in Excel take the contents of worksheet cells as their arguments—for example, SUM(A2:A10). Some functions have additional arguments that you use to fine-tune the analysis. You’ll see much more about these functions in later chapters, but a straightforward example involves the FREQUENCY() function, which was introduced in Chapter 1:

=FREQUENCY(B2:B11,E2:E6)

In this example, suppose that you wanted to categorize the price per gallon data in Figure 2.2 into five groups: less than \$1, between \$1 and \$2, between \$2 and \$3, and so on. You could define the limits of those groups by entering the value at the upper limit of the range—that is, \$1, \$2, \$3, \$4, and so on—in cells E2:E6. The FREQUENCY() function expects that you will use its first argument to tell it where the individual observations are (here, they’re in B2:B11, called the data array by Excel) and that you’ll use its second argument to tell it where to find the boundaries of the groups (here, E2:E6, called the bins array).

So in the case of the FREQUENCY() function, the arguments have different purposes: The data array argument contains the range address of the values that you want to group, and the bins array argument contains the range address of the boundaries you want to use for the bins. The arguments behave differently according to their position in the argument list.

Contrast that with something such as =SUM(A1,A2,A3), where the SUM() function expects each of its arguments to act in the same fashion: to contribute to the total.

To use worksheet functions properly, you must be aware of the purpose of each one of a function’s arguments. Excel gives you an assist with that. When you start to enter a function into a cell in an Excel worksheet, a small pop-up window appears with the fx symbol at the left of the names (and descriptions) of functions that match what you’ve typed so far. If you double-click the fx symbol, the pop-up window is replaced by one that displays the function name and its arguments. See Figure 2.2, where the user has just begun entering the FREQUENCY() function.

Figure 2.2

The individual observations are found in the data_array, and the bin boundaries are found in the bins_array. Excel is often finicky about the order in which you supply the arguments. In the prior example, for instance, you get a very different (and very wrong) result if you incorrectly give the bins array address first:

=FREQUENCY(E2:E6,B2:B11)

The order matters if the arguments serve different purposes, as they do in the FREQUENCY() function. If they all serve the same purpose, the order doesn’t matter. For example, =SUM(A2:A10,B2:B10) is equivalent to =SUM(B2:B10,A2:A10) because the only arguments to the SUM() function are its addends.

#### Defining Return

One final bit of terminology used in functions: When a function calculates its result using the arguments you have supplied, it displays the result in the cell where you entered the function. This process is termed returning the result. For example, the AVERAGE() function returns the mean of the values you supply.

### Understanding Formulas, Results, and Formats

It’s important to be able to distinguish between a formula, the formula’s results, and what the results look like in your worksheet. A friend of mine didn’t bother to understand the distinctions, and as a consequence he failed a very elementary computer literacy course.

My friend knew that among other learning objectives he was supposed to show how to use a formula to add together the numbers in two worksheet cells and show the result of the addition in a third cell. The numbers 11 and 14 were in A1 and A2, respectively. Because he didn’t understand the difference between a formula and the result of a formula, he entered the actual sum, 25, in A3, instead of the formula =A1+A2. When he learned that he’d failed the test, he was surprised to find out that “There’s some way they can tell that you didn’t enter the formula.”

What could I say? He was pre-law.

Earlier, this chapter discussed the following example of the use of a simple statistical function:

=AVERAGE(B2:B11)

In fact, that’s a formula. An Excel formula begins with an equal sign (=). This particular formula consists of a function name (here, AVERAGE) and its arguments (here, B2:B11).

In the normal course of events, after you have finished entering a formula into a worksheet cell, Excel responds as follows:

• The formula itself, including any function and arguments involved, appears in the formula box.
• The result of the formula—in this case, what the function returns—appears in the cell where you entered the formula.
• The precise result of the formula might or might not appear in that cell, depending on the cell format that you have specified. For example, if you have limited the number of decimal places that can show up in the cell, the result may appear less precise.

I used the phrase “normal course of events” just now because there are steps you sometimes take to override them (see Figure 2.3).

Figure 2.3

The formula bar contains the name box, on the left, and the formula box, on the right. Notice these three aspects of the worksheet in Figure 2.3: The formula itself is visible in the formula box, its result is visible in cell B13, and its result can also be seen with a different appearance in cell B15.

#### Visible Formulas

The formula itself appears in the formula box. But if you wanted, you could set the protection for cell B13, or B15, to Hidden. Then, if you also protect the worksheet, the formula would not appear in the formula box. Usually, though, the formula box shows you the formula or the static value you’ve entered in the cell.

#### Visible Results

The result of the formula appears in the cell where the formula is entered. In Figure 2.3, you see the mean price per gallon for 10 gas stations in cells B13 and B15. But you could instead see the formulas in the cells. There is a Show Formulas toggle button in the Formula Auditing section of the Ribbon’s Formulas tab. Click it to change from values to formulas and back to values. Another, slower way to toggle the display of values and formulas is to click the File tab and choose Options from the navigation bar. Click Advanced in the Excel Options window and scroll down to the Display Options for This Worksheet area. Fill the check box labeled Show Formulas in Cells Instead of Their Calculated Results.

#### Same Result, Different Appearance

In Figure 2.3, the same formula is in cell B15 as in cell B13, but the formula appears to return a different result. Actually, both formulas return the value 3.697. But cell B13 is formatted to show currency, and United States currency formats display two decimal values only, by convention. So, if you call for the currency format and your operating system is using U.S. currency conventions, the display is adjusted to show just two decimals. You can change the number of decimals displayed if you wish, by selecting the cell and then clicking either the Increase Decimal or the Decrease Decimal button in the Number group on the Home tab.

The mean has a special characteristic that makes it more useful for certain intermediate and advanced statistical analyses than the median and the mode. That characteristic has to do with the distance of each individual observation from the mean of those observations.

Suppose that you have a list of 10 numbers—say, the ages of all your close relatives. Pluck another number out of the air. Subtract that number from each of the 10 ages and square the result of each subtraction. Now, find the total of all 10 squared differences.

If the number that you chose, the one that you subtracted from each of the 10 ages, happens to be the mean of the 10 ages, then the total of the squared differences is minimized (thus the term least squares). That total is smaller than it would be if you chose any number other than the mean. This outcome probably seems a strange thing to care about, but it turns out to be an important characteristic of many statistical analyses, as you’ll see in later chapters of this book.

Here’s a concrete example. Figure 2.4 shows the height of each of 10 people in cells A2:A11.

Using the workbook for Chapter 2 (see www.informit.com/title/9780789759054 for download information), you should fill in columns B, C, and D as described later in this section. The cells B2:B11 in Figure 2.4 then contain a value—any numeric value—that’s different from the actual mean of the 10 observations in column A. You will see that if the mean is in column B, the sum of the squared differences in cell D13 is smaller than if any other number is in column B.

To see that, you need to have made Solver available to Excel.

Solver is an add-in that comes with Microsoft Excel. You can install it from the factory disc or from the software that you downloaded to put Excel on your computer. Solver helps you backtrack to underlying values when you want them to result in a particular outcome.

For example, suppose that you have 10 numbers on a worksheet, and their mean value is 25. You want to know what the tenth number must be in order for the mean to equal 30 instead of 25. Solver can do that for you. Normally, you know your inputs and you’re seeking a result. When you know the result and want to find the necessary values of the inputs, Solver provides one way to do so.

The example in the prior paragraph is trivially simple, but it illustrates the main purpose of Solver: You specify the outcome and Solver determines the input values needed to reach the outcome.

You could use another Excel tool, Goal Seek, to solve the latter problem. But Solver offers you many more options than does Goal Seek. For example, using Solver, you can specify that you want an outcome maximized or minimized, instead of solving for a particular outcome (as required by Goal Seek). That’s relevant here because we want to find a value that minimizes the sum of the squared differences.

#### Finding and Installing Solver

It’s possible that Solver is already installed and available to Excel on your computer. To use Solver in Excel 2007 through 2016, click the Ribbon’s Data tab and find the Analysis group. If you see Solver there, you’re all set. (In Excel 2003 or earlier, check for Solver in the Tools menu.)

If you don’t find Solver on the Ribbon or in the Tools menu, take these steps in Excel 2007 through 2016:

1. Click the Ribbon’s File tab and choose Options.
3. At the bottom of the View and Manage Microsoft Office Add-Ins window, make sure that the Manage drop-down is set to Excel Add-Ins, and then click Go.
4. The Add-Ins dialog box appears. If you see Solver Add-in listed, fill its check box and click OK.

You should now find Solver in the Analysis group on the Ribbon’s Data tab.

If you’re using Excel 2003 or earlier, start by choosing Add-Ins from the Tools menu. Then complete step 4 in the preceding list.

If you didn’t find Solver in the Analysis group on the Data tab (or on the Tools menu in earlier Excel versions), and if you did not see it in the Add-Ins dialog box in step 4, then Solver was not installed with Excel. You will have to rerun the installation routine, and you can usually do so via the Programs item in the Windows Control Panel.

The sequence varies according to the operating system you’re running, but you should choose to change features for Microsoft Office. Expand the Excel option by clicking the plus sign by its icon and then do the same for Add-ins. Click the drop-down by Solver and choose Run from My Computer. Complete the installation sequence. When it’s through, you should be able to make the Solver add-in available to Excel using the sequence of four steps provided earlier in this section.

#### Setting Up the Worksheet for Solver

With the actual observations in A2:A11, as shown in Figure 2.4, continue by taking these steps:

1. Enter any number in cell G2. It is 0 in Figure 2.4, but you could use 10 or 1066 or 3.1416 if you prefer. When you’re through with these steps, you’ll find the mean of the values in A2:A11 has replaced the value you now begin with in cell G2.
2. In cell B2, enter this formula:
=\$G\$2
3. Copy and paste the formula in B2 into B3:B11. Because the dollar signs in the cell address make it a fixed reference, you will find that each cell in B2:B11 contains the same formula. And because the formulas point to cell G2, whatever number is there also appears in B2:B11.
4. In cell C2, enter this formula:
=A2B2
5. Copy and paste the formula in C2 into C3:C11. The range C2:C11 now contains the differences between each individual observation and whatever value you chose to put in cell G2.
6. In cell D2, enter the following formula, which uses the caret as an exponentiation operator to return the square of the value in cell C2:
=C2^2
7. Copy and paste the formula in D2 into D3:D11. The range D2:D11 now contains the squared differences between each individual observation and whatever number you entered in cell G2.
8. To get the sum of the squared differences, enter this formula in cell D13:
=SUM(D2:D11)
9. Now start Solver. With cell D13 selected, click the Data tab and locate the Analysis group. Click Solver to bring up the dialog box shown in Figure 2.5.

Figure 2.5

The Set Objective field should contain the cell you want Solver to maximize, minimize, or set to a specific value. 10. You want to minimize the sum of the squared differences, so choose the Min option button.
11. Because D13 was the active cell when you started Solver, it is the address that appears in the Set Objective field. Click in the By Changing Variable Cells box and then click in cell G2. This establishes the cell whose value Solver will modify.
12. Click Solve.

Solver now iterates through a sequence of values for cell G2. It stops when its internal decision-making rules determine that it has found a minimum value for cell D13 and that testing more values in cell G2 won’t help. At that point Solver displays a Solver Results dialog box. Choose to keep Solver’s solution or to restore the original values, and click OK.

Using the data given in Figure 2.4, Solver finishes with a value of 68.8 in cell G2 (see Figure 2.6). Because of the way that the worksheet was set up, that’s the value that now appears in cells B2:B11, and it’s the basis for the differences in C2:C11 and the squared differences in D2:D11. The sum of the squared differences in D13 is minimized, and the value in cell G2 that’s responsible for the minimum sum of the squared differences—or, in more typical statistical jargon, least squares—is the mean of the values in A2:A11.

A few comments on this demonstration:

• It works with any set of real numbers and a set of any size. Supply some numbers, total their squared differences from some other number, and then tell Solver to minimize that sum. The result will always be the mean of the original set.
• This is a demonstration, not a proof. The proof that the squared differences from the mean sum to a smaller total than from any other number is not complex and it can be found in a variety of sources.
• This discussion uses the terms differences and squared differences. You’ll find that it’s more common in statistical analysis to speak and write in terms of deviations and squared deviations.

This has to be the most roundabout way of calculating a mean ever devised. The AVERAGE() function, for example, is lots simpler. But the exercise using Solver in this section is important for two reasons:

• Understanding other concepts, including correlation, regression, and the general linear model, will come much easier if you have a good feel for the relationship between the mean of a set of scores and the concept of minimizing squared deviations.
• If you have not yet used Excel’s Solver, you have now had a glimpse of it, although in the context of a problem solved much more quickly using other tools.

I have used a very simple statistical function, AVERAGE(), as a context to discuss some basics of functions and formulas in Excel. These basics apply to all Excel’s mathematical and statistical functions, and to many functions in other categories as well. You’ll need to know about some other aspects of functions, but I’ll pick them up as we get to them: They’re much more specific than the issues discussed in this chapter.

It’s time to get on to the next measure of central tendency: the median.