final code for twogaussian