Init random generator before calling rand()

Init random generator before calling `rand()`.