Changed the interface of sample (use Rng)