density function now returns two matrices.