added discretize_weight and gaussian functions for step 3