Is it possible to find Median of set contains string value as well as Null value?

696 Views Asked by At

I am doing one calculation on Median and AFSIK about Median, it can be calculated by a "set of Finite set of Numbers".

Now if a set has following value as:

A = {3,4.56, 2, 11, JAMES, , Joy, 54, 9}

Then how will Median of such set can be calculated???

2

There are 2 best solutions below

0
On

A median depends on the ordering of the values. If you can for any two different values decide which one of them is greater you can calculate the median. In your example you could choose alphabetic ordering.

0
On

Sure, but you need to put a pretty artificial ordering on your elements, and you need an odd number of elements (although see below). Say your ordering is numbers comes before words, numbers have their usual ordering, words are lexicographically ordered, and null comes first. Then your set in order is (,2,3,4.56, 9, 11, 54, 9, JAMES, Joy) Unfortunately, that examples has ten elements. The 5th and 6th elements are 9 and 11 so you could average the two an call the median 10. In general though, you would need a way to average two elements for even sized sets.

I've never seen anyone do this though.