# Determine Median for even Number of Values

Question by Guest | 2014-02-22 at 20:20

Usually, you are determining the median by sorting the values according to their size and the median is just the middle value taken from this rank order.

So, as an example, given the values 5, 3, 1, 7, 2, we would sort them (1, 2, 3, 5, 7) and the median would be 3.

However, this principle is only applicable when having an odd number of values. Given an even number of values such as 1, 2, 3, 5 as an median, both, 2 and 3 are suitable.

So, what can you do in this case (except hoping that both middle values are equal)? Or is it not possible to determine a median if your sample size is not uneven?

## Related Topics

### MySQL: Find next higher and lower number compared to a value

Question | 1 Answer

### JavaScript: Get current Date and Time

Tutorial | 1 Comment

### MySQL: Determine the larger of two values

Question | 1 Answer

### MySQL: SELECT 0 instead of NULL

Question | 4 Answers

### PHP: Determine last digit of a number

Question | 1 Answer

### PHP: Determine Number of Elements in an Array / Length of Array

Tip | 0 Comments

### PHP: Get first Digit of Number or String

Tutorial | 0 Comments

## Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

## Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.

Normally, the median for an even number of values is the average (arithmetic mean) of both middle values.So, in your case for the numbers 1, 2, 3, 5, the two middle values are 2 and 3 and the mean of them is (2+3)/2 = 2.5. And this is the median.

However, if the median has to be part of the sample/has to occur in the values, you can also determine the upper median (3 in your case) or the lower median (2 in your case) by taking the best next value from the sample. But, as I said, usually, you are just taking the mean of the two middle values.

2014-02-22 at 20:47