How random is random?

Luth

Lex Luthor!
Reaction score
41
Every 499 seconds over an 1:40 hour game, I display I2S(GetRandomInt(0, 36)). Every B.net game (not WE games with fixed seeds), I see the same numbers far too often. Every game, without exception, I see 26. Often multiple times in the same game.

Is this normal? Is there any Seed function I can call to get a better set of random pulls?
 

Tonks

New Member
Reaction score
160
Computers can't really be entirely random. There's always a pattern, somewhere. Chances are, that pattern is intensely complex and long and difficult to figure out. Does it really matter though? It's pretty random, anyway, isn't it?
 

Luth

Lex Luthor!
Reaction score
41
Tonks said:
Computers can't really be entirely random. There's always a pattern, somewhere. Chances are, that pattern is intensely complex and long and difficult to figure out. Does it really matter though? It's pretty random, anyway, isn't it?

1) Yes, I know how random functions work. I've written them before.
2) It does matter, as if you'd read above, its entirely not random, and I'm seeing the same 3 numbers repeated again and again, game after game, for a week now, with very infrequent other results.

If you draw 10 random numbers beetween 0 and 36, and you get 26 six times, then something is wrong with the random function, it can be assumed.

So there's no seed or reseed function?
 
M

Mythic Fr0st

Guest
hmm

Hmm, I get the same thing with strings...

however, with 100-150 strings that display, out of 100 the same word appears maybe only 1-3 times each, probably 4 for the occasional rare one..

If you have enough numbers, its more likely to repeat less, thats the only thing I could think of -.-
 

Sim

Forum Administrator
Staff member
Reaction score
534
Random is meant to have numbers come out more often, simply because chances happen at random. Random numbers aren't meant to come out at least once each. They are meant to appear *randomly*, that means not equally divided, but RANDOMLY! :p

That would also mean that 1 number can appear more than another, and a second number only 1 time out of 500 tries. Because it is random. There are no rules. Try rolling dices, the same will happen. You could get 6 times a "7" roll in-a-row with a perfectly balanced die. But it doesn't mean randomness itself is screwed because of it.

Maybe randomness is miscalculated in JASS' functions, though. Dunno!

Just my 2 cents :p
 
V

Virgin-Flesh

Guest
It sounds like you have too much time on your hands ;)
There is a native function in common.j:
SetRandomSeed (integer seed)
Try messing with that.
 

Luth

Lex Luthor!
Reaction score
41
Virgin-Flesh said:
It sounds like you have too much time on your hands ;)
There is a native function in common.j:
SetRandomSeed (integer seed)
Try messing with that.

Perfect. :) Thanks for answering the question.

Dax, you should familiarize yourself with the notion of statistical probability; its what random functions mimic, and when they dont, there's something wrong.
 

N2o)

Retired.
Reaction score
51
Hmm i made a horse racing map for my mate, with random move speed and a betting system. I could bet the 1st 5 horses from memory and they'd win.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> If you draw 10 random numbers beetween 0 and 36, and you get 26 six times, then ...

Well, if that's not random...



With 10 tries of "Random integer from 1 to 2" and these results:
1212121212,
1122112211,
1111122222,
1111111112,
1221112222.

Which one is more random?
 
B

bakasora

Guest
Player 12 drop items
Events
Unit - A unit owned by Player 12 (Brown) Dies
Conditions
And - All (Conditions) are true
Conditions
((Triggering unit) is A ground unit) Equal to True
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Random integer number between 1 and 100) Less than or equal to 5
Then - Actions
Item - Create Tome of Agility at (Position of (Triggering unit))
Else - Actions
Do nothing


5% chance to drop?
how random can it be
 

Mr Zero

Junior Regular (Got the T-shirt)
Reaction score
64
AceHart said:
> If you draw 10 random numbers beetween 0 and 36, and you get 26 six times, then ...

Well, if that's not random...



With 10 tries of "Random integer from 1 to 2" and these results:
1212121212,
1122112211,
1111122222,
1111111112,
1221112222.

Which one is more random?

Haha, I wanna know one of them is the random :p.

But if you choose random you can get 1 all the time since there is no rules (unless you choose the start number).

Maybe you have a better system :rolleyes:?
 

Luth

Lex Luthor!
Reaction score
41
AceHart said:
> If you draw 10 random numbers beetween 0 and 36, and you get 26 six times, then ...

Well, if that's not random...



With 10 tries of "Random integer from 1 to 2" and these results:
1212121212,
1122112211,
1111122222,
1111111112,
1221112222.

Which one is more random?


That's 60% on 50% odds. Thats within normal standard deviation tolerance. 60% on a 2.77% bet is not. Those chances are roughly 1 in 2.4 billion to hit 60% accuracy on those odds.

Can it happen by random happenstance? Yes. However, if it does happen, being thinking creatures (well, most of us, anyway), we can look at it and say "Hey, there's probably something else influencing these results." So it seems to me that their Rand func is either not being properly seeded in B.net games, or the Rand func isnt well written. However, its likely that they're using the std C library's rand() func, which I know to be adaquate, hence the (now answered) question about Seeding.

So now I have it being periodically reseeded based on player events (such as chat strings) which are not likely to yield duplicate results. Today marks a new week of testing, so we'll see if it works as planned. :cool:
 
T

ThePixelator

Guest
I have the problem of non-randomness also. I have a map I made, and there is a random hero function. EVERY game, without exception, ever, out of the 54 times I have played with a full 10 players (yes I have counted), there has always been a blademaster and a shadow hunter. ALWAYS. out of 30 heros. Thats not random, and dont try to tell me it is.

If there is a better way to get random choices, I REALLY wanna know. Like, +rep wanna know. And, unlike some of the previous responses, try to avoid jass please, it scares me. :D

EDIT: PS. I have absolutely no idea what seeding is in any way, shape, or form, and no idea how the random functions work.
 
G

Goauld

Guest
Well, if Warcraft III had a better random function it would probably require a better system because of that.

If you want more randomness you could do from each integer variable from 1 to random number between 2 and 57, and then set variable to a random number between 0 and 36, and then use the last it gets, or even better use array and use random array of it.
 

Luth

Lex Luthor!
Reaction score
41
I put this trigger in. I'll be testing its results this week. (Hopefully far less 26s) It reseeds the random number generator every 5 minutes with the string length of the next-typed chat message + a random int. (No real reason why I used both; I'm mostly just sick of seeing 26) :cool:

Feel free to try your own tests with it, or something similiar:
Code:
 Seed Random
    Events
        Player - Player 1 (Red) types a chat message containing <Empty String> as A substring
        Player - Player 2 (Blue) types a chat message containing <Empty String> as A substring
        Player - Player 3 (Teal) types a chat message containing <Empty String> as A substring
        Player - Player 4 (Purple) types a chat message containing <Empty String> as A substring
        Player - Player 5 (Yellow) types a chat message containing <Empty String> as A substring
        Player - Player 6 (Orange) types a chat message containing <Empty String> as A substring
        Player - Player 7 (Green) types a chat message containing <Empty String> as A substring
        Player - Player 8 (Pink) types a chat message containing <Empty String> as A substring
        Player - Player 9 (Gray) types a chat message containing <Empty String> as A substring
        Player - Player 10 (Light Blue) types a chat message containing <Empty String> as A substring
    Conditions
    Actions
        Custom script:   call SetRandomSeed( StringLength(GetEventPlayerChatString()) + GetRandomInt(7,777))
        Trigger - Turn off (This trigger)
        Wait 300.00 seconds
        Trigger - Turn on (This trigger)
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> That's 60% on 50% odds.
> That's within normal standard deviation tolerance.
> 60% on a 2.77% bet is not.
> Those chances are roughly 1 in 2.4 billion to hit 60% accuracy on those odds.

Uhm... what?

> Can it happen by random happenstance? Yes.

Well, if that's not random...


> ALWAYS. Out of 30 Heroes.

Well, if that's not random...


Actually, if "random" does not meet your expectations.. it is random.
There is no "I got '1' 99 times, if I don't get '2' now, random is broken"...
Random doesn't keep any history.

And, using a custom seed only makes sense if you want to repeat a given sequence.
Otherwise, the one provided by the game will certainly beat yours.
It has better choices, like the computer's running time, or some internal CPU scratch register.
String length is a rather limited choice.
And using the random generator to seed itself can't improve its quality.



And, to answer my own question from up here, each result is equally likely, and equally random.


John von Neumann said:
Anyone who considers arithmetical methods of producing random numbers is, of course, in a state of sin.
 

Luth

Lex Luthor!
Reaction score
41
> > That's 60% on 50% odds.
> > That's within normal standard deviation tolerance.
> > 60% on a 2.77% bet is not.
> > Those chances are roughly 1 in 2.4 billion to hit 60% accuracy on those odds.

> Uhm... what?

Its statistics. Unweighted choice between 1 and 2 yields 50% odds for either for either one. Unweighted choice between 0 and 36 is (actually, I was off. I calced 36 numbers instead of 37) 2.70% for any one coming up. The chance of hitting one number between 0 and 36 with a 60% success rate is about (3.11 x 10^-8)% chance in happening, or (again, 37 instead of 36) 1 in 3,213,743,427.

> > Can it happen by random happenstance? Yes.

> Well, if that's not random...

It appears to not be random.


> > ALWAYS. Out of 30 Heroes.

> Well, if that's not random...

It appears to not be random.


> Actually, if "random" does not meet your expectations.. it is random.
> There is no "I got '1' 99 times, if I don't get '2' now, random is broken"...
> Random doesn't keep any history.

Which is why I cant claim for sure that Random is broken. The best I can do is provide statistical analysis, which I have. Statistically speaking, if your strictly non-random equation for generating "random" numbers does not come close to matching the probability of distributions, it is 'broken'. It'd be akin to: int Random(int low, int high) { return low; }. You can call it a random function, but because it doesnt come close the matching the probability of distributions, it is 'broken' or, at least, works very poorly.

> And, using a custom seed only makes sense if you want to repeat a given sequence.
> Otherwise, the one provided by the game will certainly beat yours.

Maybe, but I am putting my bet on not. Its internal seeding mechanism is giving me a 60% success rate on a 2.7% bet. With those odds, I would take $10 and break vegas in an hour.


> It has better choices, like the computer's running time, or some internal CPU scratch register.
> String length is a rather limited choice.
> And using the random generator to seed itself can't improve its quality.

If I get a higher than 60% success rate with this new seeding system, then thats evidence that my system performs worse than theirs. If I get lower, then thats evidence that my system performs better than theirs. If you ignore statistics, then you're just stating opinion, and thats not worth discussing.
 
T

ThePixelator

Guest
You just told me that "randomly" getting the 2 same heros out of 30 heros, 54 times in a row without exception, is random. Do you realize that if it really is randomly choosing the heros, then the chance of this happening is 3240 to 1 (I think). So I SERIOUSLY doubt that it really is random.

There is some pattern it is following, a very baddly written, VERY not-random pattern.
 

Luth

Lex Luthor!
Reaction score
41
Well, chances are it's using the C-lib rand() function, which is adaquate. Programers are lazy, and unless there's a reason to rewrite something that exists, we wont. :) Typically, too, we seed the rand with GetClockTick or something equally non-repeatable. However, its possible that they chose a poor seed factor, which is why we many people see unexpected repetitions. I would wager, between those two choices, its the later.

Also...
I just tested my seeder on B.net. Not one duplicate number, and not once did 26 turn up in 1 hr 40 mis. The first time ever. :cool:
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top