I have data like this.
Ram,500
Sam,400
Test,100
Ram,800
Sam,700
Test,300
Ram,900
Sam,800
Test,400
What is the shortest way to fine the "median" from above data. My result should be something like...
Median = 1/2(n+1), where n is the number of data values in the sample.
Test 500
Sam 700
Ram 800
To find the median, calculate the mean by adding together the middle values and dividing them by two.
Median formula when a data set is even Determine if the number of values, n, is even. Locate the two numbers in the middle of the data set. Find the average of the two middle numbers by adding them together and dividing the sum by two. The result of this average is the median.
Take these two steps to calculate the mean: Step 1: Add all the scores together. Step 2: Divide the sum by the number of scores used.
Python 3.4 includes statistics built-in, so you can use the method statistics.median
:
>>> from statistics import median
>>> median([1, 3, 5])
3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With