Function that returns running statistics of the same shape as the input. The function ignores NaNs and masked data (from masked arrays).