You are viewing a single comment's thread. Return to all comments →
Refined Version by importing bisect
import bisect def runningMedian(a): medians = [] arr = [] for i, n in enumerate(a, 1): # bisection bisect.insort(arr, n) # median m = i // 2 if i % 2: medians.append(round(arr[m], 1)) else: medians.append(round((arr[m] + arr[m-1]) / 2, 1)) return medians
Seems like cookies are disabled on this browser, please enable them to open this website
Find the Running Median
You are viewing a single comment's thread. Return to all comments →
Refined Version by importing bisect