John Cuthber Posted December 20, 2019 Posted December 20, 2019 On 5/23/2019 at 8:09 AM, Sensei said: Typical way C/C++ programmer is using the most basic C language built-in pseudo-random numbers generator is: srand( time( NULL ) ); int value = rand(); to get value in range in 0....RAND_MAX (0x7fff = 32767) Time is input parameter to so called random seed. The same seed, the same sequence of numbers returned by rand() function. But time (in seconds if returned by time() function) is changing, so each execution output sequence will be different. At least until overflow. srand() takes 32 bit unsigned integer as parameter, so overflow will happen after 2^32 / 60 / 60 / 24 / 365.25 = ~ 136 years (ignoring timezone changes) Non-standard pseudo-random number generators typically use current time (better with millisecond/microsecond precision) of machine to initialize random seed (srand()-equivalent function parameter). So, if I have two computers running at the same time and they both use this method, they will always generate the same "random" number. That seems the very antithesis of randomness.
Strange Posted December 20, 2019 Posted December 20, 2019 2 minutes ago, John Cuthber said: So, if I have two computers running at the same time and they both use this method, they will always generate the same "random" number. That seems the very antithesis of randomness. It is not the antithesis, but it is not "truly" random (the clue is in the name ) You can define (or measure) randomness in statistical terms (how evenly spread are the set of numbers, for example). A good PRNG will be able to match a true random source for many of these. But it will repeat (exactly) at the end of the sequence. And any two systems implementing the same PRNG will produce the same results. In a lot of cases, this is a useful feature. For example, spread-spectrum transmission works by multiplying a signal with a PRNG. This makes the signal look like noise but mean that a receiver (using the same PRNG) can detect/decode the signal by convolving the input "noise" with the PRNG sequence, thus picking it out of the really random background noise.
studiot Posted December 20, 2019 Posted December 20, 2019 17 minutes ago, Strange said: 25 minutes ago, John Cuthber said: So, if I have two computers running at the same time and they both use this method, they will always generate the same "random" number. That seems the very antithesis of randomness. It is not the antithesis, but it is not "truly" random (the clue is in the name ) You can define (or measure) randomness in statistical terms (how evenly spread are the set of numbers, for example). A good PRNG will be able to match a true random source for many of these. But it will repeat (exactly) at the end of the sequence. And any two systems implementing the same PRNG will produce the same results. In a lot of cases, this is a useful feature. For example, spread-spectrum transmission works by multiplying a signal with a PRNG. This makes the signal look like noise but mean that a receiver (using the same PRNG) can detect/decode the signal by convolving the input "noise" with the PRNG sequence, thus picking it out of the really random background noise. Well I think that shows enormous insight. Does it imply that if I fire off two instances of a 'random' process from the same trigger, I should measure identical results? eg If I have two alpha paticle generators and fire off single alpha particles at identiclal targets together I should measure identical scattering? Or if I let two s electrons in two hydrogen atoms start from the same point at the same time I should find them at the same place a fixed time later?
Strange Posted December 20, 2019 Posted December 20, 2019 21 minutes ago, studiot said: Does it imply that if I fire off two instances of a 'random' process from the same trigger, I should measure identical results? eg If I have two alpha paticle generators and fire off single alpha particles at identiclal targets together I should measure identical scattering? Or if I let two s electrons in two hydrogen atoms start from the same point at the same time I should find them at the same place a fixed time later? Well, no. Because those things are (as far as we know) truly random. (I'm not sure what "truly random" means or even if it is possible to define it rigorously.)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now