function f = adpmedian(g, Smax) if(Smax