set seed before sampling for exact reproduciblity

perhaps this is not needed for an "advanced" book because hopefully everyone reading this already knows about seeding, but it could be nice to be able to copy-paste code chunks with randomness and get the exact same output