Median function and self defined function in window


#1

Hello,

I found the median function is not applicable in the window aggregation?

Besides, if I want to apply my own function within a window, for example, a linear combination of the neighbors for each of the pixel, is there a convenient way to do this with SciDB ?

Thanks and Regards,
Meng


#2

Hi Meng!

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.

There’s example code for an aggregate here viewtopic.php?f=18&t=1122 . It’s a little old unfortunately.

There’s a newer example of a financial nbbo aggregate here: github.com/Paradigm4/quotes/blo … egates.cpp