Computer Science Canada Randint Not so random?

 Author: Archi [ Thu Jul 10, 2003 9:58 am ] Post subject: Randint Not so random? I've done quite a few tests on this and I've found that the randint function likes to pick large numbers rather than small numbers. Is there a way to make it chose more smaller numbers than large?? or is it just screwed up?

 Author: krishon [ Thu Jul 10, 2003 10:25 am ] Post subject: well its just random...i dunno...unless u want to lower the range...

 Author: rizzix [ Thu Jul 10, 2003 11:17 am ] Post subject: i wonder how they implemented this random function.. if it is based on some funny math.. it is not random .. and they did a terrible job.. otherwise they did a terrible job... o well

 Author: Homer_simpson [ Thu Jul 10, 2003 2:40 pm ] Post subject: i believe it works by getting the system time and doing some "funny math" on it...

 Author: Tony [ Thu Jul 10, 2003 3:54 pm ] Post subject: it is... it seeds the function with system time and does "funny" math to get a number in between the specified range. So techincally you're more likely to get a sertain number at sertain time of the hour. although I think that consequtive picks are seeded with result from the last run of the function (or they just seed with systemtime + milliseconds) since I remember that in v3 you used to get the same random number untill the second was over. Ether way, there is no fuction to produce a truly random number, although they fake it quite well (apparently, not well enough)

Author:  AsianSensation [ Thu Jul 10, 2003 6:23 pm ]
Post subject:

yeah, tony's right, the thing is based on time...

 code: put Rand.Int (1,100)

press F1 like crazy, you'll see that you get the same answer for a while, then it changes, weird eh?

You would think that "Random" means random, but apparently, "Random" is based on time...

 Author: Catalyst [ Thu Jul 10, 2003 7:06 pm ] Post subject: using time is one of the only ways to generate pseudo-random numbers effectiely

 Author: Tony [ Thu Jul 10, 2003 7:38 pm ] Post subject: well time is usually used as a seed for the function, although that number could come from any other source that frequently changes in value. That being said, if the first seed comes from time and sequential seeds come from result of the previous random function (as a lot of programs do out there), then it is in fact possible to have a list of all the random numbers generated available before they happen if you start the program at the exact second (or just freeze your system clock, ether way)

 Author: Dan [ Thu Jul 10, 2003 7:41 pm ] Post subject: Catalyst wrote:using time is one of the only ways to generate pseudo-random numbers effectiely ture, but this only gets the random seeds for the numbers, there is a standred mathmatic equaction to make pseudo-random numbers. here is the stander mathical equation for pseudorandom numbers: next = next * 1103515245 + 12345 rannum = (next/65536) % maxrannum this gives you pseudorandom numbers but will all ways be the same numbers, thats why you need a random seed to keep the number sets difrent. a seed is sipely the starting value of next. most randomly grentated numbers are realted to system time b/c it is the strating value of next. also the number of rannum is ushley rounded or just the decmales cut off for ints. and thats how it is done Edit: this was posted b4 i saw tonys post. dam you beat me

 Author: rizzix [ Thu Jul 10, 2003 8:01 pm ] Post subject: now-a-days it is prefered to gather ethropy fomr keyboard / mouse movements etc.. its much much better than using the system time. i know for a fact advanced encryption applications use it. (i use one all the time... try PGP.. or GPG.. reall fun.. i think all compsci member should have such an application installed [for windows just go for PGP] ... not just because of the "super duper top secret stuff we do here", but it's fun!)

 Author: Dan [ Thu Jul 10, 2003 8:20 pm ] Post subject: i whould just like to add that i dont think turing uses that foraml b/c it whould over flow if the ranum number was biger then 2. this is due to turing only using a max of 4 beyts to make int, nat, real, and other varibales. i do think this is how c at least used to do it. aslo for poleop who dont know the % is the same as mod fuction in turing

Author:  SilverSprite [ Thu Jul 10, 2003 8:39 pm ]
Post subject:

AsianSensation wrote:
yeah, tony's right, the thing is based on time...

 code: put Rand.Int (1,100)

press F1 like crazy, you'll see that you get the same answer for a while, then it changes, weird eh?

You would think that "Random" means random, but apparently, "Random" is based on time...

If you can come up with a better random that means random then by all means.. but this is good enough for now.. anyways yeah random is based on time but hm i know that you can change the seed in c++ i think that in turing the keyword randomize does the equivalent.. but it slows the program down alot!

 Author: Mazer [ Thu Jul 10, 2003 8:52 pm ] Post subject: just a second kiddies. edit: damnit all, i just wrote this big ass paragraph explaining the random numbers in turing and just noticed it's already been explained twice. damn you all. well, not all of you.

 Author: SilverSprite [ Thu Jul 10, 2003 8:57 pm ] Post subject: well this thread started a long time ago .. you must be real slow

 Author: AsianSensation [ Thu Jul 10, 2003 9:00 pm ] Post subject: what exactly does Randomize do in turing? I've heard that they made it obsolete, and it has no use in the newer version (4.0.some letter)

 Author: SilverSprite [ Thu Jul 10, 2003 9:03 pm ] Post subject: did you not read what i posted? it provides a new seed

 Author: AsianSensation [ Thu Jul 10, 2003 9:06 pm ] Post subject: lol, who cares about what you say anyways? jk I guess I missed that part... so why is it made obsolete now? isn't it still useful then, if it provides with a new seed?

 Author: rizzix [ Thu Jul 10, 2003 9:07 pm ] Post subject: it is used at start-up or something.. **we're at teh chat room**

 Author: SilverSprite [ Thu Jul 10, 2003 9:08 pm ] Post subject: cuz its turing.. nobody needs to use randomize for anything useful.. and again you didnt read what i said.. it makes the program real slow..

 Author: Tony [ Thu Jul 10, 2003 11:27 pm ] Post subject: here's the deal with randomize: in old days of DOS turing randint was just that... randint... and it was seeded by system time. Now that just means that for a whole second you'll be getting the same "random" number. So to fix this, randomize marked the flag in the function to seed itself with previously generated number... Now, then the WinOOT came out, they still kept the randomize even though it is executed by default now. They kept it just so that those who are "used" to old sytax could still type it Basically the same reason we got drawfillbox() and Draw.FillBox(). Cuz Tom is nuts and is making a crappy language with 5 spellings for same command.

 Author: Dan [ Fri Jul 11, 2003 1:51 am ] Post subject: tony wrote:Cuz Tom is nuts and is making a crappy language with 5 spellings for same command. lol, thats my way to make a language. increas the odds of geting it right the 1st time, lol.

 Author: PaddyLong [ Fri Jul 11, 2003 12:48 pm ] Post subject: I like the sounds of that.

 :