Random number?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
batatinha
Prole
Posts: 22
Joined: Mon Jun 24, 2013 3:49 am

Re: Random number?

Post by batatinha »

Robin wrote:...
Now i'm VERY confused... Why it runs fine on LOVE and not on Lua?
User avatar
Plu
Inner party member
Posts: 722
Joined: Fri Mar 15, 2013 9:36 pm

Re: Random number?

Post by Plu »

I'm not proposing here to possess ultimate randomness power, I simply claim that additional randomizing slightly improves pseudo-random generated pattern by breaking it apart at really random positions. You don't even have to really apply this in your programs, you will most likely never notice the pattern if you use random just like normal. But if you do, randomization helps. Random mess of small randomly torn chunks of a total pattern is better than plain total pattern. You don't need any real experiment to confirm this, a simple common sense gives you an idea that it's true. But if you want it that bad, I can write you a random.dll that has very short internal pattern since it will only use, like, 4 bits or something, and then you can perform real experiment, as a proof of concept.
That's not neccesarily how randomness works. Especially the part about "common sense"; common and sense and higher mathematics don't mix. There is no common sense reason to believe that random chunks of a random pattern are any more random than the random pattern itself. Trust the mathematics guys who've been posting here on that one.
Now i'm VERY confused... Why it runs fine on LOVE and not on Lua?
I think the problem is that your seeds are too big, which is causing the system to cast them to 0. As explained by Boolsheet:
batatinha, the issue that your seed isn't working as expected probably comes from the fact that you're trying to give it a 43-bit long number and somwhere in the conversion process (be it Lua oder VC++) this gets turned into 0. math.randomseed calls the C function srand that expects the type unsinged int which is 32-bit on most of today's systems. Limit the number you get from gettime by doing a modulo operation on it and the conversion will work as expected.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Random number?

Post by raidho36 »

That's not neccesarily how randomness works. Especially the part about "common sense"; common and sense and higher mathematics don't mix. There is no common sense reason to believe that random chunks of a random pattern are any more random than the random pattern itself.
Oh yeah? Watch. Upper strip is 2x8 pattern. Lower strip is composed of randomly placed chunks of upper srip cut to random length. You can still see the pattern chunks, but it's isn't half as bad.

Just before you ask source, I simply drew it. It was faster that way. But I actually used randomized brush to land pixels, and I was copy-pasting top to bottom with fast inaccurate strokes. And of course you can make this same program with pseudorand function that returns you a color from lookup table rather than usning real random. It yields same behavior, just on very small scale.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Random number?

Post by Robin »

raidho36 wrote:
For the reasons above, the two lists will be the same up to a cyclic rotation.
Only that rand doesn't return ALL bits that revolve arond inside, there's a little more is going on. So pattern may be way longer than RAND_MAX, and even than INT_MAX for that matter.
While the cycle would probably (and hopefully) be longer than RAND_MAX. It can't possibly be longer than UINT_MAX (just shy of twice INT_MAX), because there aren't enough bits of state for a longer cycle. Probably, It'll be a shorter cycle. In that case, picking a different seed may end you up in a different cycle, which is interesting.
raidho36 wrote:How am I supposed to re-code you exactly the program I used back then, so you could see it?
If it's so hard to show the "pattern" effect you propose exists, it would hardly be relevant to us, because we're never going to see the pattern anyway.
raidho36 wrote:You don't need any real experiment to confirm this, a simple common sense gives you an idea that it's true.
My common sense tells me it's false. If you want to convince me, vrld and the other people here, you'd better show some actual results, not just make vague claims.
batatinha wrote:Now i'm VERY confused... Why it runs fine on LOVE and not on Lua?
Are you using Windows? I think the problem is that the Windows stdlib has a really bad PRNG.
Help us help you: attach a .love.
Automatik
Citizen
Posts: 57
Joined: Sun Feb 17, 2013 7:05 pm

Re: Random number?

Post by Automatik »

The only argument raidho36 is willing (and maybe able) to provide is "just trust me, alright?". This isn't going to work.
How am I supposed to re-code you exactly the program I used back then, so you could see it?[/quote]

You don't have to re-code it exactly. But if you can't reproduce it, you have no proof.
Besides, I'm not proposing here to possess ultimate randomness power, I simply claim that additional randomizing slightly improves pseudo-random generated pattern by breaking it apart at really random positions.
Without any good proof.
You don't need any real experiment to confirm this, a simple common sense gives you an idea that it's true.
Yes we do. You can't rely on the "common sense" argument for a subject as complex as randomization.
why math.randomseed(math.random()) is more random?
It's not any more random, I just used the wrong term (and already acknowledged it). I mean that it makes noticeable patterns less likely.
Ok, so ,why?
User avatar
Plu
Inner party member
Posts: 722
Joined: Fri Mar 15, 2013 9:36 pm

Re: Random number?

Post by Plu »

raidho36 wrote:
That's not neccesarily how randomness works. Especially the part about "common sense"; common and sense and higher mathematics don't mix. There is no common sense reason to believe that random chunks of a random pattern are any more random than the random pattern itself.
Oh yeah? Watch. Upper strip is 2x8 pattern. Lower strip is composed of randomly placed chunks of upper srip cut to random length. You can still see the pattern chunks, but it's isn't half as bad.

Just before you ask source, I simply drew it. It was faster that way. But I actually used randomized brush to land pixels, and I was copy-pasting top to bottom with fast inaccurate strokes. And of course you can make this same program with pseudorand function that returns you a color from lookup table rather than usning real random. It yields same behavior, just on very small scale.
The top pattern isn't random. This is not a valid example of what you were claiming. You said that random chunks from random input are more random. That means you need to start with a random list at the top, and then show random sections of it at the bottom and show how those are more random. Obviously random chunks from an easily visible pattern are more random than said easily visible pattern, but that's not being claimed.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Random number?

Post by bartbes »

Well this is going everywhere!
Locked
Locked

Who is online

Users browsing this forum: No registered users and 13 guests