fix mean and variance function