fix density bug, optimize PRNG