Darwinbots Forum
General => Off Topic => Topic started by: Botsareus on February 25, 2005, 04:56:56 PM
-
Yes, The Visual Basics Rnd function after a period of time produces repeating data?
Any one know a soultion to this?
We can use the rnd function in combination with another really clever way to generate numbers. ex:
An example of a way will be to mesure the uncertainty of the processor and the system timer interacting and/or then uncertainty of the processor and the hard drive interacting
The ultimate source for random information will be the internet but who is going to bother with a system of collecting that information or with running DB only when pc is online.
-
Try
"randomize timer"
before each rnd event
This will pretty much never produce a repeating sequence as the seed number is always inherantly changing.
:D PY :D
-
ok I will , There is a limit on how mutch "time numbers" the program understands though
To make it even better we can make it Timer + Val(Replace(Date, "/", ""))
thanks for your help PY
But I already use "randomize" witch basicaly means "randomize timer" in my code
Here is an idea
Private Sub Form_Load()
Randomize Timer + Val(Replace(Date, "/", ""))
MsgBox Rnd(-(Timer + Rnd))
End Sub
The confusion here is:
Lets say A is not the same number over time:
Does "Randomize A" get compiled by visual basic by converting it into
"Rnd(-abs(A))" on each rnd call? or somthing close to that?
-
Bots, found a gaussian curve online from that online book I showed you. It's in C, but it isn't hard to convert it to VB.
I can't paste it here because of formatting issues, and the fact that the source is a PDF, and cause I'm lazy. But here is the section its in (http://lib-www.lanl.gov/numerical/bookcpdf/c7-2.pdf). Search for gasdev. It's at the very end.
Are we talking about the period of a random number function here?
Everyone wanting to discuss this read this introduction (http://lib-www.lanl.gov/numerical/bookcpdf/c7-0.pdf) and this section (http://lib-www.lanl.gov/numerical/bookcpdf/c7-1.pdf) on the basics of random number generation.
Basically, a computer can't produce random numbers. Well, not unless you attach a geiger counter to it and generate random bits based on that. The only source of truly random stuff is nature. But for most purposes the random number generators of a computer are good enough.
The above articles are written for C standard (my favorite language! :P :ph43r:), but you can probably figure out what's going on without too much trouble. Everything it talks about are just as true for VB as for and C compiler.
-
Thanks but its just even more confusion; I have not even learned Precalcules; And AAAAAAAAA! C~!~~!~ <_<
Can some one just give me a simple ans.:
The confusion here is:
Lets say A is not the same number over time:
Does "Randomize A" get compiled by visual basic by converting it into
"Rnd(-abs(A))" on each rnd call? or somthing close to that?
If you want Num give me a year by then I should learn Precal...
Freighting thoughts: Is collage going to exsept me if I dont know Precal??
---
I am reading , I am reading...
-
Sorry, I keep forgetting not everyone is a computer science and mathematics major :(
To answer your question, if VB works like C (and I have a hunch it does) this is how Randomize works:
Random numbers are generated from a function. The next random number is generated from the one before it. The next number should be statistically independant from the current number.
Here's a really bad but simple random function. Let's pretend this is how VB does it:
Function rand (seed as integer) as integer
rand = seed * 3 + 1
End Function
Now, all random number generators have to be 'seeded'. Since each value is made from the one before it, what do we do for the first value we want to generate? We give it a 'seed value'.
Lets say we seed our generator with "1"
So we do this:
dim seed as integer
seed = 1
while true
seed = rand(seed)
print.debug(seed)
Wend
This shows us generating a list of 'random' numbers (I told you our function was bad but simple).
This will generate the same list of 'random' numbers everytime we run the program. This is where psuedorandom space games like noctis and elite get their complexity. They only have to store a single initial seed value and they can generate a list of random numbers to build their universe from. It's the same for every time its run.
That's great, but what if we don't want the same list of random numbers everytime we run the program? Well, since seed and rand(seed) are supposed to be statistically independant, as long as we can come up with a new seed everytime we run the program we can make a new, completely different random list.
What changes everytime the program is run? That's right, the timer! That blasted little bugger's been running down since sometime in the 1970s. Always increasing, counting on and on, never tiring.
So we convert that timer value into whatever data format we're using, in my example an integer, and we use that as the seed each time the program's run.
That's what's happening when you type Randomize Timer.
Colleges will accept people that don't even know algebra. Just means you get to pay them more money :rolleyes:
-
Thanks Num. The next random number is generated from the one before it. Time to go write a new function for smexe.
-
If you're making a new random number function (its kind of fun in a way) and you'd like to test if your new random number function is actually producing random numbers, you can try a simple stats correlation test. You can do it in a Texas Instruments Ti83 plus (standard graphing calculator) by inputting all the numbers you get into a list and doing different regressions on it. You should see a r^2 value of close to 0. The closer to zero it is, the more random it is.
If you don't have a graphinc calculator, maybe you can find a similar program on the internet. Or you can make your own! Look up the algorithms for regression curves on any simple stats page on the internet.
Try exponential, linear, quadratic, logarithmic, and any others you can think of.
-
ok :ph43r: <--- thats supposed to be a ninja right?
-
I'm not sure what emotion it's supposed to convey but it sure does look cool. :ph43r:
-
How long does it take for VB's random function to repeat itself? I.e. how many values can it take?
-
I think I know but Mighty should reply to "The English" first
:bigginangel: Bau :bigginangel:
:evil: Bau :evil:
-
That topic had gone off topic by the third post. I'm really not sure if I have anything to add.
I only want to know if it's more than 2^64 values...
-
Yes there are more, Maybe 2 ^ 150 is close. But I dont have a computer science major so I dont know for sure.
-
Assuming you have the computer generate a new number every second, it should take 4.5382061861071679164704351389191e+37 years for the function to repeat itself. Note that the universe is only 1.37e+9 years old (http://www.space.com/scienceastronomy/map_discovery_030211.html). Why on earth do you feel the need to make it more random? :huh:
Oh well, each to their own, I suppose...
Numsgil, how many instructions would a P4 have to perform when you call the random function?
-
The Stuff I do: #1 I generate about 225000 rnd calls a second. And #2 if you simply use "timer" it will repeat again the same if the program is run on the same exact instant. It takes maybe 1 second for the program to reload so for every new load there is maybe a 1/1000 chance that the program is going to use an old randomize sequence. But gess what with my new code I fixed bouth of these problems.
-
Good News is that it did improve the work of my program. Have not seen any Ms-Dos yet though.
-
4.5382061861071679164704351389191e+37 / 225000 = 2.016980527158741296209082283964e+32
:D
-
The Point is it does work better. Lets see what Num has to say....
Yea, with the math you did MP, it does seem perfect. But its not.
-
How do you run two instances of the program in the same instant?
-
Two processors?
-
I can't find any information on the VB random number generator, or how good it is, or what its period is.
For one program I needed to generate at least 200 billion random numbers, so there are times when you need a good random number generator.
DB probably isn't there yet, but I love talking about random numbers!
-
I was Basing it on the msdn help for the rnd function.
I also did a timed test too see aprox. the number of rnd calls in two seconds.
/ 2 x 45 running smexe: came out to 225000 calls per second.
Forgive me if I messed this one up but somthing like:
Form_load()
show
Do
j = j + 1
if (timer) /2 = (timer) \2 then msgbox j 'forget about the fact thats it has to do the
'loop code and the j++ code ... ;)
Loop
End Sub
-
OK gess what the rnd function DOES NOT WORK LIKE THIS
newrndnumberinlist = rnd(-oldrandomnumber)
<>
newrndnumberinlist = rnd
The Truth is no one has a clue were vb gets its next random number in stack from:
newrndnumberinlist = rnd(-???????)
Ok here is the second thing that people should look out for:
lets say you have a number that changes in low range: 0.001 , 0.002 , 0.003....
DO NOT ADD ANY HIGH RANGE NUMBERs like 700000 TO IT EX:
70000.001 , 70000.002 , 7000 0.003 ...
IT WILL LOSE SENSATIVITY TO LOWER RANGE CHANGE
rnd(-(rnd+70000)) <------ not so good idea.
Finaly , If you want to make the random function more powerfull you have first run the list:
For I = 0 to 1000000
thelist(I) = rnd
next
into memory,
Then combine it later with your own random numbers:
yourownrandomnumber = rnd(-cpuflux)
t = t +1
'COMBINE ONLY USING ATN() FUNCTION , I use getang as a custom atn using function
result = rnd(-(getang( rnd(-yourownrandomnumber) -0.5 , rnd(-thelist(t)) -0.5 )/360)
-
I'm sticky-ing this thread because every two or three months I go hunting for that incredibly book with the chapters I posted near the beginning of the thread, and have to hunt this damn thign down.
-
I know how to create a perfect randomizer, give a radiation detector, some radioactive material, connect the detecter to the computer and create random or logical things it will become random cause the radioactive material decay is completly random ^_^ thats the perfect randomizer.
-
I know how to create a perfect randomizer, give a radiation detector, some radioactive material, connect the detecter to the computer and create random or logical things it will become random cause the radioactive material decay is completly random ^_^ thats the perfect randomizer.
I am not in disagreement my friend ...
I think that is as close as one can come.
but even if what you say is so ...
how would one ever be able to verify that? ;)
to catch any 'mistake' it made ...
or to verify it did not ...
you would have to employ a system of observation
that is more random than the one you are observing.
it's like trying to see the eye with the eye ...
or to understand the mind using the mind.
as long as there is a subject/object split ...
there exists this division/duality ...
a part that is observer ...
which is separate from the observed.
so our very looking/questioning ...
alters what we find.
is it not so?
-
I'm sticky-ing this thread because every two or three months I go hunting for that incredibly book with the chapters I posted near the beginning of the thread, and have to hunt this damn thign down.
yeah. thanks Num ... a good read.
-
You can find the whole book here (http://library.lanl.gov/numerical/).
There are some outright amazing stuff in there beyond even just random numbers. Some of the math I've started learning in my 400 level math courses, to give you an idea of the difficulty...
-
I tried the random in vb and it worx very well if you use both date and time, cause each second and hour and day is different so it wont repeat for a very long time and then its very random
-
Yes, but you know nothing of what the computer is using to decide the random numbers, or what the period of the VB random function is, or how statistically random it is, etc.
-
Yes, but you know nothing of what the computer is using to decide the random numbers, or what the period of the VB random function is, or how statistically random it is, etc.
good enough for who's using it. ;)
-
Right, you only need a good random number generator for scientific computing, and other times like that.
-
yeah, but aint a good randomizer needed for ALs?
-
I've done a couple of different tests of DB's randomness, and found it to be pretty good. The two main tests were a coin flipping bot and an ouija board bot.
The coin flipper basically tested if the rnd numbers were weighted towards one end or another for:
1 rnd 50 addstore.
*50 *.robage div 51 store
'Average of all random flips
There were no problems found.
The Ouija bot was to test if the rnd nums could form different words(alright too much watching White Noise that night :) )
' 27 therefore 28 random nums 0 and 27 representing space and period respectivly
27 rnd 50 store
27 rnd 51 store
*51 100 mult *50 add 70 store
' for a two letter word
I basically did the above many more times to wind up with 10 letters per cycle.
No words or ghosts were in evidence at the time, unless they were highly concerned with acronyms. :wacko:
For me this proves DB's randomness works reasonably well and doesn't need improvement.
Oh yeah, Zelos:
Added up a Whimsical section on the wiki if you're interested in making up a Db early history.
-
I were thinking more on mutation randomizing
-
I would say you'd want your mutations to be properly statistically randomo. Why is why I copied some of the source in those random number chapters above for the C++ source.
-
Reminded me of this.
(http://dilbert.com/dyn/str_strip/000000000/00000000/0000000/000000/00000/2000/300/2318/2318.strip.gif)
-
I actually had a discussion going on MythBusters forums on how to make a truly random r.n.g. We where looking into using windows performance graphs built into the .net framework. The only thing that came out of that was it will be extremely platform specific and therefor completely unpractical.
On the flip side, the advantage of 'seeded' r.n.g. is the fact that it is extremely easy to debug. If you know 'when' the program crashed and what 'seed' was used, all you need to do is put the same seed back into the system and wait for the program to crash at the same exact 'time.' I am using time in quoty marks because I am thinking in terms of cycles not actual time.
-
Did someone implement it, I wonder how random the results it gives would be.
-
Well you want to be careful about the difference between unpredictability and random. Random implies a certain uniformity and shape to the numbers you get back over the long haul. I imagine if you tried to hook in to random noisy things in the computer you could generate unpredictable bits, but they might by skewed so far in one direction that they end up being useless for a RNG.
-
If it's unpredictable, it's random. If a unpredictable number-generator doesn't return uniformity in the long run, it means you can predict what numbers it will more likely get.
It is rather complicated to find out if a number-generator is 'random', but you got tools (http://csrc.nist.gov/groups/ST/toolkit/rng/documentation_software.html) for that.
-
Your best bet is to flush in the noisy stuff into an existing RNG. But be careful, because that will usually simplify the randomization instead of improving it unless you figure out the frequency and amplitude on this things.
I wish I had more for you then that. But the .net version of the RNG .net inherited from vb6 is only single precision. And I don't know the .net's "Random Class" that well to run experiments.