How Does A Random Number Generator Work?

I always had a query. I have really good software development background (although I am a Mechanical Engineer by education & profession). How do random number generators work?

A thought experiment: Have two systems (one much faster than the other) ready with the same rand(). Start the program at the same time on both the systems. The slower system computes a random number with whatever logic it adopts and takes time "x". The faster system can generate the same number in time less than "x". So what is totally randomly generated for the user of the slower system is not so random after all, if he calls up the user of the faster system as gets to know the number beforehand.

Please provide answers and neglect the seemingly absurd thought experiment.

Replies

  • Ramani Aswath
    Ramani Aswath
    I do not get this.
    In an excel sheet you fill as many cells as you want with the rand() function. They all get filled with different random numbers at the same time.
  • Shashank Moghe
    Shashank Moghe
    A.V.Ramani
    I do not get this.
    In an excel sheet you fill as many cells as you want with the rand() function. They all get filled with different random numbers at the same time.
    All I am saying is, what is the underlying logic in generating a random number? There must be some logic that has to be used, and that undermines the whole point of it being random. A faster computer can run the same logic and can provide you with this "random" number while the slower computer still works on the same rand() program. Turns out, for the slower computer, the number computed isn't random at all (since it is already outputted by the faster computer).

    The concept of randomness, to me, is how Erwin Schrodinger used in the famous cat experiment. He assumed a radioactive substance so small in amount that in an hour probably only one atom decays (or may be doesn't). Depending on that decay event (or the lack of it), the fate of the cat is decided. Now that, is true randomness.

    To cut the long story short, if logic (no matter what logic, as long as its logic or a sequential chain of ideas) is employed, a random number is never truly generated.

    I am sorry for this pathetic explanation, but I am sure you get my point here. I appreciate your inputs.
  • Ramani Aswath
    Ramani Aswath
    The rand() function generates a 'pseudorandom' number not a true random number. However, it would happen rarely that two machines (whatever their speeds) would produce the same output.
    I do not know the process. Some 'seed' is used, which may be chosen in some way by the programme which further processes this seed to generate the pseudo random number.
    This article gives some more info:
    RANDOM.ORG - Introduction to Randomness and Random Numbers
  • Shashank Moghe
    Shashank Moghe
    A.V.Ramani
    The rand() function generates a 'pseudorandom' number not a true random number. However, it would happen rarely that two machines (whatever their speeds) would produce the same output.
    I do not know the process. Some 'seed' is used, which may be chosen in some way by the programme which further processes this seed to generate the pseudo random number.
    This article gives some more info:
    RANDOM.ORG - Introduction to Randomness and Random Numbers

    Excellent article. It confirms that the functions like rand() are pseudo random number generators. If the "seed" is the same, a faster computer will yield the same number faster than the slower one. This is what I meant. Now we know (and the article confirms) that these numbers are not truly random, but can be reproduced with the same starting "seed" and periodic (the sequence of numbers generated is repeatable).

    This brings me to my next question, although this time I have better knowledge (thanks to A.V Ramani sir) - Is there a true random number generator function?
  • avii
    avii
    ^There is no true random generator, afaik.
  • pratap singh, upendra
    pratap singh, upendra
    The machine starts with a particular number(at its own discretion) and applies certain algorithm like least squares method etc. to generate further sequence of random numbers.

    Also the two machines may start with two different numbers and at the same time they may also make use of different algorithms to further their sequence.
    So, it is fair enough to state that two machine will rarely generate the same set of random numbers after every input pulse given to them.

    Also remember that for a particular machine, random numbers in the sequence are not mutually independent. They are always linked through some algorithm( the same algorithm that was used to generate the sequence). For this reason, random numbers are not strictly random, rather they are pseudo-random numbers.
  • Shashank Moghe
    Shashank Moghe
    proffy
    The machine starts with a particular number(at its own discretion) and applies certain algorithm like least squares method etc. to generate further sequence of random numbers.

    Also the two machines may start with two different numbers and at the same time they may also make use of different algorithms to further their sequence.
    So, it is fair enough to state that two machine will rarely generate the same set of random numbers after every input pulse given to them.

    Also remember that for a particular machine, random numbers in the sequence are not mutually independent. They are always linked through some algorithm( the same algorithm that was used to generate the sequence). For this reason, random numbers are not strictly random, rather they are pseudo-random numbers.

    Well, I am getting opposing ideas from your reply. Anyhow, I don't quite digest the idea that a defined flow of logic can lead to a truly random number. Even when you say the "seeds" can be randomly selected, I believe even this random selection has some logic. The point being, you cannot truly have a random number if you have written the code to generate one.

    One stupid idea I had when I used to use the rand() a lot was that the code made use of the slight fluctuations in voltage from the grid to somehow compute the random numbers. These fluctuations are transient and hence can be fairly random. But then again, I thought if a supercomputer connected to the grid had the rand(), it would already know the output, much before my company PC could generate one 😀
  • Ramani Aswath
    Ramani Aswath
    shashank Moghe
    Excellent article. Is there a true random number generator function?
    The later part of the article does discuss this issue and shows why it is a cumbersome time consuming process. All TRNGs require an external random event input (like ambient noise).
  • Shashank Moghe
    Shashank Moghe
    A.V.Ramani
    The later part of the article does discuss this issue and shows why it is a cumbersome time consuming process. All TRNGs require an external random event input (like ambient noise).
    I get it is cumbersome, and probably even expensive. But the question was to whether there is capability on my work desk PC to generate a truly random number. And I guess I got the answer, thanks to the article you shared and other valuable responses from CEans.

You are reading an archived discussion.

Related Posts

what is the reason for the input impedence in the open circuit transmission line to behave inductive or capacitive...?i came to know that depending upon value(+ve or -ve) of (Bl)...
While Apple had everybody’s attention during its iPhone 6 and Apple Watch launch event, Qualcomm Technologies announced a slew of new processors that will bring 4G LTE connectivity equipped smartphones...
Let me introduce myself, im Cesar Balderas from Mexico, im a last year IT engineer student, I joined CE because I was looking for ideas to apply in my 2...
Many of us have experienced the irritating flash of light from an oncoming vehicle while steering along a highway during the late hours. At that time, we just toddle along...
The Flipkart Flash Sale model and thousands of buyers waiting to buy the Xiaomi Redmi 1S smartphone has created a lot of buzz about the new smartphone from the Chinese...