## Overview

The terms mean, median and mode are used to describe the central tendency of a large data set. Range provides provides context for the mean, median and mode.Without these three methods of calculation, it would be impossible to interpret much of the data we use in daily life. Each is used to find the statistical midpoint in a group of numbers, but they all do so differently.

### Mean

When people talk about statistical averages, they are referring to the mean. To calculate the mean, simply add all of your numbers together. Next, divide the sum by however many numbers you added. The result is your *mean *or average score.

For example, let's say you have four test scores: 15, 18, 22, and 20. To find the average, you would first add all four scores together, then divide the sum by four. The resulting mean is 18.75. Written out, it looks something like this:

(15 + 18 + 22 + 20) / 4 = 75 / 4 = 18.75

# we can use python3 functions as to calculate mean.

Lets assume numbers = [15, 18, 22, 20]

#By using sum function

>>>s = sum(numbers)

>>>s/len(numbers)

18.75

# By using numpy

>>>import numpy as np

>>>np.mean(numbers)

18.75 # we get the output

# we can also use pandas library while working to get mean of large dataset

>>>import pandas as pd

>>>df = pd.Series(numbers)

>>>df.mean()

18.75

### Median

The median is the middle value in a data set. To calculate it, place all of your numbers in increasing order. If you have an odd number of integers, the next step is to find the middle number on your list. In this example, the middle or median number is 15:

numbers = 3, 9, 15, 17, 44

If you have an even number of data points, calculating the median requires another step or two. First, find the two middle integers in your list. Add them together, then divide by two. The result is the median number. In this example, the two middle numbers are 8 and 12:

numbers = 3, 6, 8, 12, 17, 44.

Written out, the calculation would look like this: (8 + 12) / 2 = 20 / 2 = 10

# By using numpy

>>>numbers = [3, 6, 8, 12, 17, 44]

>>>import numpy as np

>>>np.median(numbers)

10.0 # we get the output

# we can also use pandas library while working to get median of large dataset

>>>import pandas as pd

>>>df = pd.Series(numbers)

>>>df.median()

10.0

### Mode

In statistics, the mode in a list of numbers refers to the integers that occur most frequently. Unlike the median and mean, the mode is about the frequency of occurrence. There can be more than one mode or no mode at all; it all depends on the data set itself. For example, let's say you have the following list of numbers:

numbers = [4, 4, 9, 9, 15, 15, 15, 17, 17, 27, 30, 44, 55]

In this case, the mode is 15 because it is the integer that appears most often. However, if there were one fewer 15 in your list, then you would have four modes: 4, 9 and 17.

>>>numbers = [4, 4, 9, 9, 15, 15, 15, 17, 17, 27, 30, 44, 55]

# we can use pandas library while working to get mode of large dataset

>>>import pandas as pd

>>>df = pd.Series(numbers)

>>>df.mode()

0 15

dtype: Int64

# We can use scipy library as well to calculate mode

>>>from scipy import stats

>>>stats.mode(numbers)

ModeResult(mode=array([15]), count=array([3]))

### Range

The range is simply the smallest number subtracted from the largest number in your set. For example, let's use the following numbers:

numbers = [3, 6, 9, 15, 44]

To calculate the range, you would subtract 3 from 44, giving you a range of 41. Written out, the equation looks like this:

44 - 3 = 41

>>>max(numbers) - min(numbers)

41

Categories: #Statistics Tags: #Data Science #Statistics #Mean #Median #Mode