generic robust stat function