Join Curt Frye for an in-depth discussion in this video Finding the mean, median, and commonest value, part of Mathematica 10 Essential Training.

- When you gather data you can analyze it using a number of techniques. One very common technique is to find the average or Mean of all of the values in your data set. In this movie I will show you how to find an average in Mathematica 10 as well as how to identify the Median or middle value and find the most common values in the list. I'm working in a blank Mathematica notebook so I need to enter in some data. I'll call it list5 and I'll use the = to assign a list to it.

Type a { followed by 7,24,81,95,81,5,10 then a } and shift + enter. So there's my list. If I want to find the average then I use the Mean keyword. Mean is the statistical term for the average, but even statisticians often use average in their normal conversations. So to display the average or Mean of the values in list5 I would use the keyword Mean, M-e-a-n, capital M [ and then the name of the variable, list5] and shift +enter and I see the value 303 divided by 7.

If I want to get the numerical value all I need to do is click the numerical value link in the bar beneath the result Mathematica creates an N formula. In other words it uses the N function to evaluate the previous result and I see 43.2857. If I want to find the middle value in a sorted list then I can use the Median function. So what do I mean by the Median or the middle value? Well let's say that I were to sort the values in list5 in ascending order.

I would go 5,7,10,24,81,81,95. The Median is the fourth value in that seven value list. So the values 1 to3 are less than or equal to it and the values from 5 to 7 are greater than or equal to it. So whatever is in the middle in position number 4 is the Median. So to find the Median I would type the keyword Median, M-e-d-i-a-n [list5] and shift + enter and I see the value is 24.

So again we have 5, 7, and 10, 81, 81, 95 with 24 in the middle. But now let's take a look at what happens if there are an even number of values. To do that I will Append a value to list5. So I'll type list5 = Append then [list5 That's the list that I'm adding a value to, and let's add the value 14 then ] and shift + enter.

Okay there's my new list. Now I'll type Median[list5] shift + enter and I see the value of 19. So how did I get that value? You probably notice that the value 19 occurs nowhere within this particular list. Instead what Mathematica did was take a look at the middle values. So we have 5, 7, and 10 and then 14 and 24. Those are the middle values, 14 and 24.

It then calculated the average of those two values. So 24 + 14 is 38, divided in half is 19 and that's where you get 19. If I had entered 15 instead of 14 then the Median would be 19.5. Now let's say that I want to find the most common values in the list. In this list right now the most common value is 81. It occurs twice. In Mathematica you use the Commonest keyword, so that is C-o-m-m-o-n-e-s-t[ and then the name of the variable which is list5 and a ] and shift + enter.

And we see that it returns what we expected, 81 which occurs twice versus all the other values that occur once. But now let's say that we have multiple values that occur multiple times. Let's say that I have a second value of 10 for example. I will add that. So I'll say list5 = Append [ then list5, 10 so there would be a second instance of the value 10 ] and shift + enter. Okay, there are my values.

Now if I type Commonest[list5 then a ] and shift + enter I get 81 and 10. That means that those values are tied for the most occurrences. If you've ever worked in Microsoft Excel then you might be familiar with the Mode function. The Mode function works exactly the same way that Commenest does in Mathmetica.

###### Released

6/24/2015*Mathematica 10 Essential Training*teaches information workers how to analyze data using the Mathematica 10 environment and language. After completing the course, members will be able to set up Mathematica notebooks, import data, use operators to perform simple calculations, create and manipulate lists, perform matrix calculations, analyze data using descriptive statistics, and write and debug Mathematica scripts. Author Curt Frye also shows how to visualize data with charts, convert files into the Computable Document Format, and add animation to make your results more interactive.

- Managing notebooks
- Working with operators
- Assigning values to variables
- Importing and exporting data
- Creating advanced formulas
- Creating and manipulating lists
- Manipulating arrays
- Analyzing data with descriptive analytics
- Manipulating matrices
- Managing scripts
- Creating charts
- Formatting data

## Share this video

## Embed this video

Video: Finding the mean, median, and commonest value