SciDB draws a distinction between functions (which are applied to a scalar and return a scalar) and aggregates (which are applied to a set and return a scalar). So you can write a median() aggregate and use it in window, variable_window, group aggregates, cumulate or regrid. In fact there is one implementation of that in the P4 EE library. Exact medians are complex since there isn’t an algorithm that doesn’t have O(n) space requirements. But with windows, n is as big as the window size.