Forum Moderators: coopster

Message Too Old, No Replies

what is rand based on?

is it based on time?

         

cuce

11:00 pm on Aug 10, 2006 (gmt 0)

10+ Year Member



I was just wondering what the php rand function is based on? how does it come up with these random numbers?

is it based on time?

thanks

omoutop

9:55 am on Aug 11, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You may find all the info for rand() here [gr2.php.net]

trillianjedi

10:38 am on Aug 11, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That's a bigger question that it might at first seem. Various chipsets/processors do this in a different way (some are based on random noise for example, others are based on time).

Many of these are not truly random. If you're building something for use in encryption systems online, you might want to take a look at something like this:-

[random.org...]

TJ

henry0

10:48 am on Aug 11, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks TJ,
I plan to give it a try.

For the PHP community:
Be advised that the PHP/HTTP D-load does not work
Instead use "save target as"

trillianjedi

11:01 am on Aug 11, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's quite an interesting concept isn't it.

The way the random.org random number generator works is quite simple. A radio is tuned into a frequency where nobody is broadcasting.

The atmospheric noise picked up by the receiver is fed into a Sun SPARC workstation through the microphone port where it is sampled by a program as an eight bit mono signal at a frequency of 8KHz. The upper seven bits of each sample are discarded immediately and the remaining bits are gathered and turned into a stream of bits with a high content of entropy. Skew correction is performed on the bit stream, in order to ensure that there is an approximately even distribution of 0s and 1s.

Bear in mind though, that even this is not truly random, as the atmospheric noise picked up by the radio is actually a throw back from the Big Bang, coupled to atmospheric conditions and out of band signals/interference. In fact if you tune your TV into a frequency where nobody is transmitting (just noise), 1% of that "snow" is from radio signals travelling back from the universes horizon of expansion, or at least where it was billions of light years ago (get your head around that). It is, therefore, predictable.

Just nearly impossible to predict ;)

Random number generation by computers is a big big subject.

TJ

henry0

11:09 am on Aug 11, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Funny never thought about it that way
it could be an endless quest.
Great find!

Can't you get the same result by picking up the noise/humming surrounding very high voltage above ground lines?

trillianjedi

11:37 am on Aug 11, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Can't you get the same result by picking up the noise/humming surrounding very high voltage above ground lines?

Some random number chipsets actually do something quite similar - picking up surrounding electro-magnetic radiation (which no doubt would be influenced by power lines).

So, yes, I'm absolutely certain it's possible, but, again, not truly random and although very very difficult to do, technically predictable...

It is a never ending quest. Whatever you choose to do, someone somewhere will say "ah, yes, but that's technically predictable ;)" (bit like I'm doing here hehe).

The truth is as long as it's near impossible to predict, it'll probably do.

joaquin112

8:45 pm on Aug 11, 2006 (gmt 0)

10+ Year Member



With that philosophy, truly random numbers are impossible to find... everything can be predictable by something else.