SRL Archive - Discussions and Debates

How random is random()?


Chris

2012-11-18 17:14:10

So I read this on "Random.org" a while ago:

What's this fuss about true randomness?

Perhaps you have wondered how predictable machines like computers can generate randomness. In reality, most random numbers used in computer programs are pseudo-random, which means they are generated in a predictable fashion using a mathematical formula. This is fine for many purposes, but it may not be random in the way you expect if you're used to dice rolls and lottery drawings.


When I think about it myself, I'd think that computers mainly think in 0's and 1's and that it's almost impossible to fix some randomness in there.

How does Simba actually do this?

masterBB

2012-11-18 17:29:36

I wondered this sometime ago as well. Going to look into it now.

http://xkcd.com/221/

Markus

2012-11-18 17:33:29

It uses Freepascal's PRNG, a Mersenne Twister. Uses (among others) system time as a source. Yea it's pretty secure, nothing to worry about.

KingKong

2012-11-19 01:30:08

Looks like random produces too many zeroes :(

riwu

2012-11-19 04:40:15

From: KingKong
Looks like random produces too many zeroes :(

I tested it, pretty normal result for me.
program new;
var
i, n: integer;
zero: Extended;

begin
n:= 1000000;
for i:=1 to n do
if Random(100) = 0 then
zero:= zero + 1;

writeln('% zero: ' + ToStr(zero/n*100));
end.
% zero: 0.9984
% zero: 0.9975
% zero: 1.0049
% zero: 1.0128


I don't think we have to worry about Random, it's not that easy to trace the seed of pseudo random generator, you will need to have the script running non-stop for an extended period of time. Not likely for Jagex to attempt this.

KingKong

2012-11-19 05:17:58

i somehow doubt that a random function will be called 1M times in a script, which is why i chose 1k. maybe another number occurs more often for u which we wont know unless you get the % of all the numbers

riwu

2012-11-19 05:25:05

From: KingKong
i somehow doubt that a random function will be called 1M times in a script, which is why i chose 1k. maybe another number occurs more often for u which we wont know unless you get the % of all the numbers

Hmm i don't think that matters. Having a higher number of trials helps you to get a better estimation of the true percentage. If you use a lower no. of trials, it means that the outcome may not be near its true value.

You can probably try it for all numbers but i doubt any of them will be significantly different since the random generator use an established algorithm.

KingKong

2012-11-19 05:37:52

actually the presence of many zeroes within a short trials is one of the disadvantages of mersenne gen, straight from the wiki:
Another issue is that it can take a long time to turn a non-random initial state
(notably the presence of many zeros) into output that passes randomness tests. A small lagged Fibonacci generator or linear congruential generator gets started much more quickly and usually is used to seed the Mersenne Twister with
random initial values.

riwu

2012-11-19 05:58:50

From: KingKong
actually the presence of many zeroes within a short trials is one of the disadvantages of mersenne gen, straight from the wiki:

Oh so i guess that's why i didn't get any abnormally high zeros when i try a larger number since it starts balancing as n increases.
Does it only occur to zero specifically or the first value of the generated data? i.e. like RandomRange(1, 100).

KingKong

2012-11-19 06:03:23

Im not sure, the wiki only says zero, but i will test when i get home and post the results.

weequ

2012-11-19 06:16:53

I don't think anything is random even in real life.

Mark

2012-11-19 09:07:08

Not with people like derren brown who can find patterns in randomness and predict the outcome.

OT: I wouldn't worry too much I've heard things about random not being that random and to use 3andom3ange instead but for runescape to create and algorithm to predict our randomized coords I don't think will be happening soon.

Tho it does make me wonder what if they do and how hard is this to accomplish I aways thought that something like this would be worth millions to the right person for example online gambling sites use random number generators for some games for example bingo where random numbers are generated till there's a winner.

Gu3st...

2012-11-21 05:59:20

From: weequ
I don't think anything is random even in real life.
But unfortunately we'll never get to calculate why or if that's true (provided that quantum theory isn't entirely false)

riwu

2012-11-21 06:08:30

'Random' is usually understood as having an equal probability of the events occurring, so as long as the algorithm is not biased towards any number, it can be considered random.

litoris

2012-11-21 06:11:13

It's random enough I think, one of the graphs above shows too many 0s, but that shouldn't affect much.
From: weequ
I don't think anything is random even in real life.


If we can't estimate the parameters to a certain accuracy, then it's random.
ie. you could theoretically determine the result of a coin toss if you knew everything about it, like the angular momentum of the coin in the air.

cause

2012-11-21 14:14:44

So what we can gather is that, if we were to achieve more accurate randomness, we should be doing randomness…more? In regards to
actually the presence of many zeroes within a short trials is one of the disadvantages of mersenne gen, straight from the wiki:

How can we take this theory and apply it to scripting? (Assuming we want to)

weequ

2012-11-21 15:37:04

From: litoris
It's random enough I think, one of the graphs above shows too many 0s, but that shouldn't affect much.


If we can't estimate the parameters to a certain accuracy, then it's random.
ie. you could theoretically determine the result of a coin toss if you knew everything about it, like the angular momentum of the coin in the air.
well that depends on how we determine random. I think it's something that can't even theoretically be determined from the parameters. That's why I like to think that even a coin toss isn't truly random but it just appears as random. Hence why I don't believe in free will etc.

Edit: sorry I think I'm going a bit off-topic.

Gala

2012-11-21 17:31:35

From: weequ
well that depends on how we determine random. I think it's something that can't even theoretically be determined from the parameters. That's why I like to think that even a coin toss isn't truly random but it just appears as random. Hence why I don't believe in free will etc.

Edit: sorry I think I'm going a bit off-topic.


A coin toss isn't random. I think in there are only few things really random? (Atom separation, correct me if i am wrong)

@topic
I think this thought is really interesting as I asked myself how you can get a random number only with logics (on, off).
As someone mentioned you can get a seed and use an algorith to make it fit your needs (in range x to y)

KingKong

2012-11-21 18:35:25

From: cause
So what we can gather is that, if we were to achieve more accurate randomness, we should be doing randomness…more? In regards to

How can we take this theory and apply it to scripting? (Assuming we want to)


Im not sure what you mean by applying it to scripting, do you want to take advantage of the high number of zeroes or do you mean to say that you want it to be more accurate?

riwu

2012-11-21 19:09:17

Most of the time, things are only truly random at the atomic/sub-atomic (micro) level. Eg. Heisenberg's uncertainty principle has demonstrated that the wave-particle duality property of electrons would result in an inverse proportionality in determining the position and momentum of an electron; that is, full knowledge about its momentum will cost us any knowledge about its position, and such lapse in knowledge can never be addressed by improved technology. As such it can be considered true randomness.

From: cause

How can we take this theory and apply it to scripting? (Assuming we want to)

If only '0' is affected, i guess we can simply avoid 0? i.e. RandomRange(1, 101) instead of Random(100).

If it is the first number of a range that is affected, we can simply ignore it like:

while r = 0 do
r:= Random(101);
Then we will have a 'random' number between 1-100, where the probability of r being any of the number in the range is equal.
Although if the solution were to be that easy, the algorithm would have already addressed this? So i might've overlooked something :rolleyes:

n3ss3s

2012-11-22 15:36:09

If you're concerned as far as botting etc goes, don't be. Deciphering whether a program is clicking a tree or if it's a human based on mouse randomness is next to impossible, since there is no way for Jagex to know where our point of "intended click" is, which they'd compare to the actual click. (Unless they had the dexterity of McGyver and the evilness of Blizzard and made their own Warden that detects open Simbas and emulates the script).

Even if they had a way of getting the added randomness for every click or wait, A Mersenne Twister

has a very long period of 219937 − 1

masterBB

2012-11-22 15:47:58

From: riwu
So i might've overlooked something :rolleyes:


RandomRange(a, b); = Random(1) * (b - a) + a

riwu

2012-11-22 19:10:17

From: masterBB
RandomRange(a, b); = Random(b - a) + a

Oh should have thought of that, it's still based off Random…
Guess we'll have to use the second method of re-rolling if it hits 0 then…like what n3ss said we shouldn't have to worry about this in RS though.

Sirenia

2012-11-23 03:06:29

From: n3ss3s
If you're concerned as far as botting etc goes, don't be. Deciphering whether a program is clicking a tree or if it's a human based on mouse randomness is next to impossible, since there is no way for Jagex to know where our point of "intended click" is, which they'd compare to the actual click. (Unless they had the dexterity of McGyver and the evilness of Blizzard and made their own Warden that detects open Simbas and emulates the script).

Even if they had a way of getting the added randomness for every click or wait, A Mersenne Twister

Warden is only scanning its own and the games processes, its not touching anything on your computer. If Jagex added this kind of Warden to Runescape we would be unaffected anw because Warden is only scanning for altered memory.