break a sampling function into a trajectory initialization function and a sample generating function