compute residuals based on median, update simulations