Write function called my_median which takes values in column


Problem

Write function called my_median which takes the values in a column (like salary) as input and will output the mathematical median of the values in that column.

The definition of median is:
X is the ordered list of elements
n is the number of elements in the list
Median(X) = X [(n+1)/2], if n is odd
Median(X) = (X [n/2] + X[(n/2)+1])/2, if n is event

Example:
Ordered list X = {5, 7, 10, 12, 15, 17}
Median(X) = ((X(3)+X(4))/2) = (10+12)/2 = 11

Ordered list X = {3, 5, 8, 15, 16}

Median(X) = X(3) = 8

Remember the list must be ordered, so, you must first ensure the list is ordered in your UDF. If the list input is:

X = {5, 2, 8, 1, 5} you must first order the list to X = {1, 2, 5, 5, 8}

Make sure to handle errors (like an empty list).

Your 3 calls should be:

• A list with an event amount of elements
• A list with an odd amount of elements
• An empty list.

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Write function called my_median which takes values in column
Reference No:- TGS03262134

Expected delivery within 24 Hours