2
$\begingroup$

If the clock shows 14:15:36.909302, why not just use the fractions of a second part (09302) as a kind of random number?

What is wrong with this form of generating random numbers?

I am aware that obtaining truly random numbers is a difficult task, so I am assuming that there is something wrong with this method.

$\endgroup$
1
  • 1
    $\begingroup$ What research have you done? There is lots written on this subject. $\endgroup$
    – D.W.
    Dec 31, 2013 at 22:09

2 Answers 2

8
$\begingroup$

Quick answer:

  1. If the run time of your algorithm to pick a random number is not random you could get a pattern of times which is not random.

    As an example. Suppose the function to read the time is triggered by an event, and the event is timed to the clock, now your functions based on the clock.

  2. If the run time of your algorithm is faster than the precision of the clock, then you will get duplicate times and thus duplicate numbers which are not random.

    As an example. You write a function for use by others, and someone decides to generate 10,000 random numbers and store them. The loop is so tight for reading the clock and saving the values that you get 10,000 numbers all identical.

These are just cases that can make the data non-random. In reality if it is not security related I run a large sample through a test for randomness and if it were reasonable I would use it, but if it is security related I would ask at Security or Crypto

$\endgroup$
2
-2
$\begingroup$

If you use a clock to generate a number for a roulette machine then every hour you will have 3600 seconds to use as your seed number,multiply this seed number by the same fixed number every second and you will produce a different number every second. If you make the fixed number the date then every day you will get a different sequence of numbers,even better,if you started with pi at the very beginning then the very last 4 digits could be your fixed number as pi never repeats a sequence? The number generated would be the last digit of the equation,as long as it is between Zero and 37,if it outside this range it gets disguarded and the next number used,if there are a few numbers in succession that fall outside our scale then this is when you get repeat numbers or zero!!! Any thoughts?

$\endgroup$
2
  • 2
    $\begingroup$ Please use paragraphs and notation to explain your problem better. $\endgroup$
    – padawan
    Apr 29, 2018 at 10:23
  • $\begingroup$ By "pi never repeats a sequence", I guess you mean that pi is irrational so it's not a repeating decimal (e.g., 3.141592659265926...)? $\endgroup$ Jan 13, 2019 at 0:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.