Fixed some bugs in generating a gaussian distribution