Random Numbers on Computers (in Off-topic)

AdminQBVerifex [Serenity In Chaos] May 20 2008 5:10 PM EDT

Generated by Random.org

Generated by PHP rand() function

Can you see the pattern on the second one? This is partially due to the way it generated the picture, check it out on the link below.

AdminLamuness May 20 2008 5:25 PM EDT

Guess we won't be using your dice roller for CG. ;)

QBOddBird May 20 2008 6:03 PM EDT


So from now on we should totally just do random.org rolls between 1-10 ;)

Khardin May 20 2008 7:06 PM EDT

One guy I knew used a function he called not_random where he made an array of numbers drawn from the random number generator and then indexed the array with another random number. I didn't graph it out, but I imagine it would random up the image a bit more; Which begs the question why isn't a similar simple step inherent in the function.

AdminQBVerifex [Serenity In Chaos] May 20 2008 7:19 PM EDT

I'll look into making a external call to random.org to get my dice rolls.

bartjan May 20 2008 10:14 PM EDT

QBsutekh137 May 20 2008 10:41 PM EDT

That's a good point, Khardin... Though, I assume that the random number guys and gals thought that anyone generating a random number would always choose the best algorithm, so if they chose the best algorithm, twice, it would just bunch things up, yes?

(I don't know anything about random numbers...)

I agree with you, though. Why not use a good generator for step one and then run a second, differently-thought algorithm for step two. What would that create? Hell, just make the function have a "depth" parameter. As long as you are willing to wait, the function will apply several different algorithms... I suppose you then have to worry about the gestalt collective algorithm defeating the randomness of the singular parts, though. Maybe make 3 the max? Come on, mathematicians! Where's Obscurans, he seems into this stuff...

Tyriel [123456789] May 20 2008 10:54 PM EDT


Make an pseudo random sized array of pseudo random numbers.

Take the number at a pseudo random location, multiply it by a pseudo random number. Take the number at that pseudo random location, divide it by location of the pseudo random'th instance of a pseudo random number, and multiply it by the pseudo random number at that pseudo random location. Now you have a seemingly random number. (Or you could just not. :P)

Throw in a few other things such as amount of time from a certain day (such as Jan. 1st, 2000), and you have a 'random' number.

Or, you know, you could just use Random.org, since they seem to have it down pat. :P

But, really; what's truly random? From dictionary.com: "Proceeding, made, or occurring without definite aim, reason, or pattern"

Technically, everything has a pattern.

I'm just going to stop now, before I get too carried away.

...Sorry... What was this thread about? :P

Rexozord May 21 2008 12:21 AM EDT

The propensity for humans seeing patterns where none exist does not mean that everything has a pattern. =P

QBsutekh137 May 21 2008 12:31 AM EDT

On the contrary, I think pattern recognition propensity is our greatest skill! If there does seem to be a pattern, that probably says something...

_What_ it says, however... That is definitely the question!

Rexozord May 21 2008 12:37 AM EDT

We see patterns in things like songs picked in an mp3 player's "randomly" generated list after only a small (less than one thousand) number of plays, when, realistically, it should take much longer for any true pattern to emerge. Just because we think we see a pattern, does not mean that we actually see a pattern.

(Of course, this is not to put down pattern recognition itself)

Lochnivar May 21 2008 12:40 AM EDT

there is no spoon

AdminQBVerifex [Serenity In Chaos] May 21 2008 1:17 AM EDT

Most random numbers are generated using the system clock "tick" to seed it. Since that system "tick" increments very very fast, most of the time you pull a time-slice from it to use as a random seed. If you pull slices from the system clock very quickly, you are going to see a pattern.

If you put delays in the time that you get your time-slices from the system clock, the pattern is less obvious, and therefore is more random. Of course, given a large enough sample, the pattern will still emerge. The only way to get truly random numbers is to use something borrowed from quantum mechanics.

Khardin May 21 2008 2:13 AM EDT

this article explains a lot about pseudo random number generators. it says this about C++ rand():

The Standard C++ rand() function uses a linear congruential generator. It offers a uniformly distributed bit stream quickly when the parameters m, a, c, and X0 are appropriately chosen. The LCG offers no Cryptographic Security.

X0 is colloquially referred to as the seed, often using the system time. The generator obtains numbers by using the following recurrence relation:

Xn+1 = (aXn + c) mod m
uniformly distributed bit stream suggests to me that it's made to act that way to provide quick and dirty random numbers which shouldn't be used too often or for too many values. the article also mentions a couple of students cracking netscapes secure online transaction number generator by predicting the seed. it seems to say that any method is only as basically secure as the seed which implies no function is very random at all, it only produces certain values for certain input.

Obscurans May 21 2008 9:50 AM EDT

Use the common MT19937, the Mersenne twister, it's pretty fast and I have the routine somewhere back home.

And how about this?

QBOddBird May 21 2008 9:52 AM EDT

A much better method to obtain random numbers is to get a lot of walnuts, write 1-9 on all of them, then fling them straight up into the air and try to catch them in your hat as they fall.

QBsutekh137 May 21 2008 10:01 AM EDT

I agree with you, Rex, however, the second picture in the original post definitely has a pattern. I don't think that is made up or that it is some sort of optical illusion.

There is clearly order there, and where there is order, there is not randomness.

Zoglog[T] [big bucks] May 21 2008 10:21 AM EDT

Number sequences, no matter how large the sample will eventually recur to a pattern of some sort, the pattern may not stay in the same sequence each time but sequences of numbers will still recur.
Just like with pi, although it has not yet been found there will eventually be a recurrence.

AdminNightStrike May 21 2008 10:32 AM EDT

If by "eventual" you mean "at infinity", then yes, you are correct. How long will you wait for an infinite set of numbers?
This thread is closed to new posts. However, you are welcome to reference it from a new thread; link this with the html <a href="/bboard/q-and-a-fetch-msg.tcl?msg_id=002RLL">Random Numbers on Computers</a>