[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gforth] Gforth Digest, Vol 61, Issue 3

From: James Gere
Subject: Re: [gforth] Gforth Digest, Vol 61, Issue 3
Date: Wed, 9 Aug 2017 18:44:12 -0400

On Aug 9, 2017 12:01 PM, <address@hidden> wrote:
Send Gforth mailing list submissions to

To subscribe or unsubscribe via the World Wide Web, visit
or, via email, send a message with subject or body 'help' to

You can reach the person managing the list at

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Gforth digest..."

Today's Topics:

   1. Re: how to build a really working random seed ? (address@hidden)
   2. Re: 1. (vol60, i4) Re: how to build a really working random
      seed ? (Marcel) (James Gere) (James Gere)


Message: 1
Date: Tue, 08 Aug 2017 21:27:31 +0200
From: address@hidden
To: address@hidden
Subject: Re: [gforth] how to build a really working random seed ?
Message-ID: <206d0f5528fe4603e3ab31b014bb6address@hidden>
Content-Type: text/plain; charset=US-ASCII; format=flowed

James Gere <address@hidden> writes Re: how to build a really working
random seed ?

> Dear Marcel,
>                        did you try 5 or 6?
> James Gere

No, I did not, thanks!

The generator is even more puzzling than I thought
(unless I made an conversion mistake from 32 -> 64 bits)
I don't believe you have made any mistake with the random generator, so long as there is no chance  of 64 bit excess (non-zero bits) shifting into the 32 bit values.  This would only bother the right shift, but looks ok.


-- see the test below.

It looks like you and your computer have been very busy.  Step back for a second.

The random generator is working corectly.  It's just not the same kind of generator you are used to.  The old LCGs (linear congruential generators) input a seed (a seperate operation), cycled the seed, and spit back the new seed as the random result.  The output was  always of the same period as the generator, one big cycle.

The rnd generator builds on that idea by incorporating another step, the take-off function.  Instead of just showing you the seed every time you ask, the rnd generator gives you a scrambled version of it.  In this case the take-off is:
         dup 13 lshift xor dup 17 rshift xor
The fact that the same function has dual-use just makes rnd faster and shorter.

Imagine I have a random list of ten numbers 1 to10.  If you ask me for a new number, I'll just move to the next on the list and give that to you.  If I run out of numbers, I go back to the beginning and give you the first number.

Now with a take-off function, my friend also has a list.  When you ask for my number, I give it to my friend.  He looks at my number and gives you the number that corresponds to my number from his list, which usually differs from mine.  This makes it harder for you to measure the period of my generator.

That is where the problem lies.  The latest xtest starts my list from a given seed, and counts how many steps until my friend's number matches the given.  That shows only how far out of sync the two lists are for that number.  If you want to know how long the list is, one way is to ask for rnd then count how many steps until you get the same result.  


To short circuit the test, enter
1073741825 xtest .

Apparently this generator has a cycle of 0 for the initial seed
In light of the above, this just says the two lists are in sync for this number.
I hope I have explained this clearly.  I'll keep an eye out for your questions and comments here.

                 James Gere

reply via email to

[Prev in Thread] Current Thread [Next in Thread]