diff --git a/blog/Statistics_10days-day0.html b/blog/Statistics_10days-day0.html index 1839b75..9262c48 100644 --- a/blog/Statistics_10days-day0.html +++ b/blog/Statistics_10days-day0.html @@ -136,7 +136,10 @@ For a continuous probability distribution, the median is the value such that a n

Implementation in python without using the scientific libraries

def median(l):
     l = sorted(l)
-    return (l[len(l) // 2] + l[(len(l)//2 - 1)]) / 2
+    if len(l) % 2 == 0:
+        return (l[len(l) // 2] + l[(len(l)//2 - 1)]) / 2
+    else:
+        return l[len(l)//2]
 
 def mean(l):
     return sum(l)/len(l)
@@ -182,7 +185,7 @@ Mean : 43117.75, Median : 44627.5, Mode : 4978