median->mean + mad function