Reusing sample vector mean code