Data Analysis

Setting an (almost) unique seed for a random generator

In Data Analysis and other programming endeavors, we frequently have to set a random() seed to, say, select a sample of observations from a very large dataset.

You might want to select a 10,000 sample from a million observation dataset. Good idea to avoid crashing your PC. You should use a random seed to do so.

If you truly want an (almost) unique random seed, try my tried and true method (from my IBM software engineering days) of using date/time … preferably utilizing milliseconds.

Example:  a seed of 1471300214792 milliseconds converted to date/time is 16 August 2016 01:30:14:792. Set your seed to today’s date/time in milliseconds.  You’ll never see that particular programmatical random seed in this lifetime (perhaps only if 1 million monkeys tapped on a calculator for 100+ million years… or the time it takes for Elon Musk’s Falcon Heavy-launched Tesla to fall into the sun ). Think about it.

Have fun, brainiacs.

 

Wiki