Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Computers are useless. They can only give you answers. -- Pablo Picasso


devel / comp.lang.forth / Re: RANDOM routine pulled from an old paper

SubjectAuthor
* RANDOM routine pulled from an old paperHans Bezemer
+* Re: RANDOM routine pulled from an old paperminforth
|`* Re: RANDOM routine pulled from an old paperHans Bezemer
| `* Re: RANDOM routine pulled from an old paperminforth
|  `- Re: RANDOM routine pulled from an old papermhx
+* Re: RANDOM routine pulled from an old papernone
|`- Re: RANDOM routine pulled from an old paperdxf
`* Re: RANDOM routine pulled from an old paperminforth
 `* Re: RANDOM routine pulled from an old paperminforth
  `* Re: RANDOM routine pulled from an old papermhx
   +- Re: RANDOM routine pulled from an old paperminforth
   +* Re: RANDOM routine pulled from an old papernone
   |`- Re: RANDOM routine pulled from an old papermhx
   `* Re: RANDOM routine pulled from an old paperdxf
    `- Re: RANDOM routine pulled from an old papermhx

1
RANDOM routine pulled from an old paper

<810d6f56-e2dc-48f8-9a81-a06588cd7e44n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=25125&group=comp.lang.forth#25125

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:1a04:b0:778:9071:2b3c with SMTP id bk4-20020a05620a1a0400b0077890712b3cmr30606qkb.0.1699436792431;
Wed, 08 Nov 2023 01:46:32 -0800 (PST)
X-Received: by 2002:a4a:8c50:0:b0:589:d4e9:69b3 with SMTP id
v16-20020a4a8c50000000b00589d4e969b3mr429262ooj.1.1699436792218; Wed, 08 Nov
2023 01:46:32 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Wed, 8 Nov 2023 01:46:31 -0800 (PST)
Injection-Info: google-groups.googlegroups.com; posting-host=77.174.47.232; posting-account=Ebqe4AoAAABfjCRL4ZqOHWv4jv5ZU4Cs
NNTP-Posting-Host: 77.174.47.232
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <810d6f56-e2dc-48f8-9a81-a06588cd7e44n@googlegroups.com>
Subject: RANDOM routine pulled from an old paper
From: the.beez...@gmail.com (Hans Bezemer)
Injection-Date: Wed, 08 Nov 2023 09:46:32 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2629
 by: Hans Bezemer - Wed, 8 Nov 2023 09:46 UTC

Maybe it is useful to someone. It seems to work just fine. I have no Forth-79 compiler to verify it.

: ARRAY CELLS ALLOT ;

I think it's quite obvious but anyways. The curious part is that the author seems to prefer 1-indexed arrays instead of 0-indexed ones.

Hans Bezemer

\ A Portable FORTH Random Number Generator, William T. Doyle
\ The Journal of Forth Application and Research Vol. I. Number 2. Dec. 1983

\ When seeded with the word RND.INIT the sequences produced are identical
\ to those produced by Knuth's FORTRAN subroutine with the same seed and
\ number range.

\ ANS conversion by Hans Bezemer, 2023
\ Converted to a single word version

( RANDOM NUMBER GENERATOR FORTH-79 WTD)

55 ARRAY RND DOES> SWAP 1- CELLS + ; ( 55 RANDOM NRS IN RND )

VARIABLE TALLY 0 TALLY !
VARIABLE SEED 314159296 SEED !

: CYCLE ( N I A --- N2)
DUP >R @ 1+ DUP ROT > IF DROP 1 THEN DUP R> ! ;

: STEP ( A --- N+ I)
55 TALLY CYCLE ;

( RANDOM NUMBER GENERATOR 2 )
: RND.INIT ( --- )
0 TALLY ! SEED @ DUP 55 RND !
1 SWAP 55 1 DO OVER DUP 21
I * 55 MOD RND ! - DUP 0< IF
1000000000 + THEN SWAP LOOP
DROP DROP ;

: RANDOM ( --- N)
STEP DUP >R RND @ DUP R@ DUP
25 < IF 31 + ELSE 24 - THEN RND
@ - DUP 0< IF 1000000000 +
THEN R> RND ! ;

( RANDOM NUMBER GENERATOR 3)
: WARMUP ( --- )
221 1 DO RANDOM DROP LOOP ;
: RANDOMIZE ( N --- )
TALLY ! RND.INIT WARMUP ;

0 randomize random . cr depth .

Re: RANDOM routine pulled from an old paper

<a6250518598e36d8f5da1932306df9c3@news.novabbs.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=25128&group=comp.lang.forth#25128

  copy link   Newsgroups: comp.lang.forth
Date: Wed, 8 Nov 2023 12:59:02 +0000
Subject: Re: RANDOM routine pulled from an old paper
X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on novalink.us
From: minfo...@gmx.net (minforth)
Newsgroups: comp.lang.forth
X-Rslight-Site: $2y$10$T9cL6lpAt1Q4Q0Br49.jceQAIjBPckAHa6VhBaIU5DUWOqtk1cAbS
X-Rslight-Posting-User: 0d6d33dbe0e2e1ff58b82acfc1a8a32ac3b1cb72
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
User-Agent: Rocksolid Light
References: <810d6f56-e2dc-48f8-9a81-a06588cd7e44n@googlegroups.com>
Organization: novaBBS
Message-ID: <a6250518598e36d8f5da1932306df9c3@news.novabbs.com>
 by: minforth - Wed, 8 Nov 2023 12:59 UTC

Hans Bezemer wrote:

> 55 ARRAY RND DOES> SWAP 1- CELLS + ; ( 55 RANDOM NRS IN RND )

This DOES> must either have defined interpretation semantics
or something else is missing here...

Re: RANDOM routine pulled from an old paper

<fb95a865-8705-4d9e-8b76-9df26a972c7dn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=25129&group=comp.lang.forth#25129

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:6214:16c8:b0:66d:9b:9389 with SMTP id d8-20020a05621416c800b0066d009b9389mr36061qvz.5.1699461128727;
Wed, 08 Nov 2023 08:32:08 -0800 (PST)
X-Received: by 2002:a9d:7c95:0:b0:6bc:fab5:e998 with SMTP id
q21-20020a9d7c95000000b006bcfab5e998mr686376otn.1.1699461128516; Wed, 08 Nov
2023 08:32:08 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Wed, 8 Nov 2023 08:32:08 -0800 (PST)
In-Reply-To: <a6250518598e36d8f5da1932306df9c3@news.novabbs.com>
Injection-Info: google-groups.googlegroups.com; posting-host=77.174.47.232; posting-account=Ebqe4AoAAABfjCRL4ZqOHWv4jv5ZU4Cs
NNTP-Posting-Host: 77.174.47.232
References: <810d6f56-e2dc-48f8-9a81-a06588cd7e44n@googlegroups.com> <a6250518598e36d8f5da1932306df9c3@news.novabbs.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <fb95a865-8705-4d9e-8b76-9df26a972c7dn@googlegroups.com>
Subject: Re: RANDOM routine pulled from an old paper
From: the.beez...@gmail.com (Hans Bezemer)
Injection-Date: Wed, 08 Nov 2023 16:32:08 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 1953
 by: Hans Bezemer - Wed, 8 Nov 2023 16:32 UTC

On Wednesday, November 8, 2023 at 2:02:32 PM UTC+1, minforth wrote:
> Hans Bezemer wrote:
>
> > 55 ARRAY RND DOES> SWAP 1- CELLS + ; ( 55 RANDOM NRS IN RND )
> This DOES> must either have defined interpretation semantics
> or something else is missing here...

Gforth comes with ABSOLUTELY NO WARRANTY; for details type `license'
Type `help' for basic help
: array create cells allot ; ok
55 ARRAY RND DOES> SWAP 1- CELLS + ; ok
25 1 rnd ! ok

Works fine.. As Bernd said "It's trivial to add interpretation semantics.. So why not?"

But if you're happier with ": ARRAY CREATE CELLS ALLOT DOES> SWAP 1- CELLS + ;"
then go for it. I told you: "some assembly required"..

Hans Bezemer

Re: RANDOM routine pulled from an old paper

<e2f8518ff05d98ba2490842bdea016a6@news.novabbs.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=25130&group=comp.lang.forth#25130

  copy link   Newsgroups: comp.lang.forth
Date: Wed, 8 Nov 2023 16:58:09 +0000
Subject: Re: RANDOM routine pulled from an old paper
X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on novalink.us
X-Spam-Level: *
From: minfo...@gmx.net (minforth)
Newsgroups: comp.lang.forth
X-Rslight-Site: $2y$10$BLgAMWl42QbHTYkgYhhVpOinbWCFXrCB3q/MuUIWdqf3NnyQATWfu
X-Rslight-Posting-User: 0d6d33dbe0e2e1ff58b82acfc1a8a32ac3b1cb72
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
User-Agent: Rocksolid Light
References: <810d6f56-e2dc-48f8-9a81-a06588cd7e44n@googlegroups.com> <a6250518598e36d8f5da1932306df9c3@news.novabbs.com> <fb95a865-8705-4d9e-8b76-9df26a972c7dn@googlegroups.com>
Organization: novaBBS
Message-ID: <e2f8518ff05d98ba2490842bdea016a6@news.novabbs.com>
 by: minforth - Wed, 8 Nov 2023 16:58 UTC

Hans Bezemer wrote:

> On Wednesday, November 8, 2023 at 2:02:32 PM UTC+1, minforth wrote:
>> Hans Bezemer wrote:
>>
>> > 55 ARRAY RND DOES> SWAP 1- CELLS + ; ( 55 RANDOM NRS IN RND )
>> This DOES> must either have defined interpretation semantics
>> or something else is missing here...

> Gforth comes with ABSOLUTELY NO WARRANTY; for details type `license'
> Type `help' for basic help
> : array create cells allot ; ok
> 55 ARRAY RND DOES> SWAP 1- CELLS + ; ok
> 25 1 rnd ! ok

> Works fine.. As Bernd said "It's trivial to add interpretation semantics.. So why not?"

> But if you're happier with ": ARRAY CREATE CELLS ALLOT DOES> SWAP 1- CELLS + ;"
> then go for it. I told you: "some assembly required"..

Of course. Didn't know it was done in gforth dialect.

I like my interpretative DO..LOOP or better FOR..NEXT as well.

Re: RANDOM routine pulled from an old paper

<5b443b34ad6c5a3d083185db43efea3b@news.novabbs.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=25131&group=comp.lang.forth#25131

  copy link   Newsgroups: comp.lang.forth
Date: Wed, 8 Nov 2023 17:50:31 +0000
Subject: Re: RANDOM routine pulled from an old paper
X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on novalink.us
From: mhx...@iae.nl (mhx)
Newsgroups: comp.lang.forth
X-Rslight-Site: $2y$10$nW01/1X4JoaXyy3WrpLjQet8arFjgahd3sBURVzKwAFUU0GfbGvVK
X-Rslight-Posting-User: 463cbf1a76c808942982a163321348c75477c065
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
User-Agent: Rocksolid Light
References: <810d6f56-e2dc-48f8-9a81-a06588cd7e44n@googlegroups.com> <a6250518598e36d8f5da1932306df9c3@news.novabbs.com> <fb95a865-8705-4d9e-8b76-9df26a972c7dn@googlegroups.com> <e2f8518ff05d98ba2490842bdea016a6@news.novabbs.com>
Organization: novaBBS
Message-ID: <5b443b34ad6c5a3d083185db43efea3b@news.novabbs.com>
 by: mhx - Wed, 8 Nov 2023 17:50 UTC

minforth wrote:
[..]
> Of course. Didn't know it was done in gforth dialect.

Well, from the posting's comments one might think it is a truthful
copy of the code in the original paper, for 16-bit Forth79.

Assuming William Boyle did not have a 64-bit Forth79 compiler,
"314159296" and "1000000000" differ from the original critical
constants. This makes it doubtful the generator has the
statistical properties Knuth intended. (Given that William
Boyd converted Knuth's Fortran code correctly! Was there ever
a Fortran with a 16-bit integer RND function?)

-marcel

Re: RANDOM routine pulled from an old paper

<nnd$7c36a778$2d52340e@a83ff788cb758c62>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=25135&group=comp.lang.forth#25135

  copy link   Newsgroups: comp.lang.forth
Newsgroups: comp.lang.forth
Subject: Re: RANDOM routine pulled from an old paper
References: <810d6f56-e2dc-48f8-9a81-a06588cd7e44n@googlegroups.com> <ec1b613d-cf8e-4bf0-ba73-eab288a15089n@googlegroups.com> <nnd$16a392ef$08f9095b@401ab3b3a7ca4973> <uil4i4$2q6cm$1@dont-email.me>
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
From: alb...@cherry (none)
Originator: albert@cherry.(none) (albert)
Message-ID: <nnd$7c36a778$2d52340e@a83ff788cb758c62>
Organization: KPN B.V.
Date: Sat, 11 Nov 2023 11:07:26 +0100
Path: i2pn2.org!i2pn.org!news.neodome.net!feeder1.feed.usenet.farm!feed.usenet.farm!feed.abavia.com!abe006.abavia.com!abp003.abavia.com!news.kpn.nl!not-for-mail
Lines: 67
Injection-Date: Sat, 11 Nov 2023 11:07:26 +0100
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
 by: none - Sat, 11 Nov 2023 10:07 UTC

In article <uil4i4$2q6cm$1@dont-email.me>, dxf <dxforth@gmail.com> wrote:
>On 10/11/2023 9:37 pm, albert wrote:
>> [..]
>> After (in ciforth)
>> WANT -scripting-
>> you can do *all* control construct in interpreter mode.
>> (It is implicit in the -s option, for scripting)
>>
>> T] and T[ switch to a temporary compile area. It is typically 4 Gbyte
>> away in a 8 Gbyte Forth, but beware of large buffers. (The same
>> mechanism is used for classes.)
>>
>> Then it is one screen worth of definitions:
>>
>> --------------------------------------------
>> "T]" WANTED
>> : IF T] POSTPONE IF ; IMMEDIATE
>> : DO T] POSTPONE DO ; IMMEDIATE
>> : ?DO T] POSTPONE ?DO ; IMMEDIATE
>> : BEGIN T] POSTPONE BEGIN ; IMMEDIATE
>> : THEN POSTPONE THEN POSTPONE T[ ; IMMEDIATE
>> : LOOP POSTPONE LOOP POSTPONE T[ ; IMMEDIATE
>> : +LOOP POSTPONE +LOOP POSTPONE T[ ; IMMEDIATE
>> : REPEAT POSTPONE REPEAT POSTPONE T[ ; IMMEDIATE
>> : UNTIL POSTPONE UNTIL POSTPONE T[ ; IMMEDIATE
>> : AGAIN POSTPONE AGAIN POSTPONE T[ ; IMMEDIATE
>> --------------------------------------------
>> It is insane to mint different words for this behaviour.
>>
>> T] and T[ is left as an exercise. Hint: they are state-smart.
>
>Do you have some examples? I'm still puzzled what these have over the
>regular functions.
>
>

A typical example is
( CRC64 ) CF: ?64 \ AvdH C2feb27

"BOUNDS" WANTED "-scripting-" WANTED HEX
\ Well the polynomial
C96C,5795,D787,0F42 CONSTANT CRC64_POLYNOMIAL \ ECMA-182
\ Auxiliary table with values for single bytes.
CREATE CRCTable
100 0 DO I 8 0 DO
DUP >R 1 RSHIFT R> 1 AND IF CRC64_POLYNOMIAL XOR THEN
LOOP , LOOP
\ For initial CRC and BUFFER COUNT pair, leave the updated CRC
: CRC-MORE BOUNDS ?DO DUP I C@ XOR 0FF AND CELLS CRCTable + @
SWAP 8 RSHIFT XOR LOOP ;
\ For BUFFER COUNT pair, leave the CRC .
: CRC64 -1 ROT ROT CRC-MORE INVERT ;
DECIMAL

------------------
Building the crc table you need not worry about a temp definition
and whether its code land in the middle of the table you want to
define. Also there is no entry in the dictionary that you never
want to use again.

Groetjes Albert
--
Don't praise the day before the evening. One swallow doesn't make spring.
You must not say "hey" before you have crossed the bridge. Don't sell the
hide of the bear until you shot it. Better one bird in the hand than ten in
the air. First gain is a cat spinning. - the Wise from Antrim -

Re: RANDOM routine pulled from an old paper

<uiprp3$8i6$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=25137&group=comp.lang.forth#25137

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: dxfo...@gmail.com (dxf)
Newsgroups: comp.lang.forth
Subject: Re: RANDOM routine pulled from an old paper
Date: Sun, 12 Nov 2023 17:36:19 +1100
Organization: A noiseless patient Spider
Lines: 70
Message-ID: <uiprp3$8i6$1@dont-email.me>
References: <810d6f56-e2dc-48f8-9a81-a06588cd7e44n@googlegroups.com>
<ec1b613d-cf8e-4bf0-ba73-eab288a15089n@googlegroups.com>
<nnd$16a392ef$08f9095b@401ab3b3a7ca4973> <uil4i4$2q6cm$1@dont-email.me>
<nnd$7c36a778$2d52340e@a83ff788cb758c62>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 12 Nov 2023 06:36:20 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f84cd5b4a29d913ae73bb8c8cb3c6d8a";
logging-data="8774"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/euYMasHNaDjLhDfGgQYEX"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:JaDCNcVD8ptueUw8huN1HULWLmM=
In-Reply-To: <nnd$7c36a778$2d52340e@a83ff788cb758c62>
Content-Language: en-GB
 by: dxf - Sun, 12 Nov 2023 06:36 UTC

On 11/11/2023 9:07 pm, albert wrote:
> In article <uil4i4$2q6cm$1@dont-email.me>, dxf <dxforth@gmail.com> wrote:
>> On 10/11/2023 9:37 pm, albert wrote:
>>> [..]
>>> After (in ciforth)
>>> WANT -scripting-
>>> you can do *all* control construct in interpreter mode.
>>> (It is implicit in the -s option, for scripting)
>>>
>>> T] and T[ switch to a temporary compile area. It is typically 4 Gbyte
>>> away in a 8 Gbyte Forth, but beware of large buffers. (The same
>>> mechanism is used for classes.)
>>>
>>> Then it is one screen worth of definitions:
>>>
>>> --------------------------------------------
>>> "T]" WANTED
>>> : IF T] POSTPONE IF ; IMMEDIATE
>>> : DO T] POSTPONE DO ; IMMEDIATE
>>> : ?DO T] POSTPONE ?DO ; IMMEDIATE
>>> : BEGIN T] POSTPONE BEGIN ; IMMEDIATE
>>> : THEN POSTPONE THEN POSTPONE T[ ; IMMEDIATE
>>> : LOOP POSTPONE LOOP POSTPONE T[ ; IMMEDIATE
>>> : +LOOP POSTPONE +LOOP POSTPONE T[ ; IMMEDIATE
>>> : REPEAT POSTPONE REPEAT POSTPONE T[ ; IMMEDIATE
>>> : UNTIL POSTPONE UNTIL POSTPONE T[ ; IMMEDIATE
>>> : AGAIN POSTPONE AGAIN POSTPONE T[ ; IMMEDIATE
>>> --------------------------------------------
>>> It is insane to mint different words for this behaviour.
>>>
>>> T] and T[ is left as an exercise. Hint: they are state-smart.
>>
>> Do you have some examples? I'm still puzzled what these have over the
>> regular functions.
>>
>>
>
> A typical example is
> ( CRC64 ) CF: ?64 \ AvdH C2feb27
>
> "BOUNDS" WANTED "-scripting-" WANTED HEX
> \ Well the polynomial
> C96C,5795,D787,0F42 CONSTANT CRC64_POLYNOMIAL \ ECMA-182
> \ Auxiliary table with values for single bytes.
> CREATE CRCTable
> 100 0 DO I 8 0 DO
> DUP >R 1 RSHIFT R> 1 AND IF CRC64_POLYNOMIAL XOR THEN
> LOOP , LOOP
> \ For initial CRC and BUFFER COUNT pair, leave the updated CRC
> : CRC-MORE BOUNDS ?DO DUP I C@ XOR 0FF AND CELLS CRCTable + @
> SWAP 8 RSHIFT XOR LOOP ;
> \ For BUFFER COUNT pair, leave the CRC .
> : CRC64 -1 ROT ROT CRC-MORE INVERT ;
> DECIMAL
>
> ------------------
> Building the crc table you need not worry about a temp definition
> and whether its code land in the middle of the table you want to
> define. Also there is no entry in the dictionary that you never
> want to use again.

I've used FORGET for that but in reality a :NONAME would have done just as well.

Re: RANDOM routine pulled from an old paper

<34b422991a9d3a4896d3211dbd3827ca@news.novabbs.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=25315&group=comp.lang.forth#25315

  copy link   Newsgroups: comp.lang.forth
Date: Mon, 4 Dec 2023 09:33:10 +0000
Subject: Re: RANDOM routine pulled from an old paper
X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on novalink.us
From: minfo...@gmx.net (minforth)
Newsgroups: comp.lang.forth
X-Rslight-Site: $2y$10$eCntgR6/npKw6MoJC00EAOazw9QrYvXcRI/B4wEmZ8PH/qljqp5l6
X-Rslight-Posting-User: 0d6d33dbe0e2e1ff58b82acfc1a8a32ac3b1cb72
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
User-Agent: Rocksolid Light
References: <810d6f56-e2dc-48f8-9a81-a06588cd7e44n@googlegroups.com>
Organization: novaBBS
Message-ID: <34b422991a9d3a4896d3211dbd3827ca@news.novabbs.com>
 by: minforth - Mon, 4 Dec 2023 09:33 UTC

Hans Bezemer wrote:

> Maybe it is useful to someone. It seems to work just fine. I have no Forth-79 compiler to verify it.

> : ARRAY CELLS ALLOT ;

> I think it's quite obvious but anyways. The curious part is that the author seems to prefer 1-indexed arrays instead of 0-indexed ones.

> Hans Bezemer

> A Portable FORTH Random Number Generator, William T. Doyle
> The Journal of Forth Application and Research Vol. I. Number 2. Dec. 1983

> When seeded with the word RND.INIT the sequences produced are identical
> to those produced by Knuth's FORTRAN subroutine with the same seed and
> number range.

> ANS conversion by Hans Bezemer, 2023
> Converted to a single word version

I would assume that this is a heuristic RNG with unclear properties,
even though it was proposed by Knuth and has his nimbus.

As for fast pseudo RNGs, I have more faith in XOR-shift or Xo(ro)shiro.
Although not statistically perfect, Marsaglia's XOR64 is probably the shortest
and about the fastest (on 64-bit CPUs) and requires only a single state cell.

IME it is by far good enough for non-cryptographic needs.

Re: RANDOM routine pulled from an old paper

<5ec43d8916060d629b6adc9b9fff36ca@news.novabbs.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=25321&group=comp.lang.forth#25321

  copy link   Newsgroups: comp.lang.forth
Date: Tue, 5 Dec 2023 08:40:50 +0000
Subject: Re: RANDOM routine pulled from an old paper
X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on novalink.us
From: minfo...@gmx.net (minforth)
Newsgroups: comp.lang.forth
X-Rslight-Site: $2y$10$Sss6y9UShI9EEquOlstUsOt/WoC.zGrCrFtQmSf/O3Xr5C7M.dOPG
X-Rslight-Posting-User: 0d6d33dbe0e2e1ff58b82acfc1a8a32ac3b1cb72
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
User-Agent: Rocksolid Light
References: <810d6f56-e2dc-48f8-9a81-a06588cd7e44n@googlegroups.com> <34b422991a9d3a4896d3211dbd3827ca@news.novabbs.com>
Organization: novaBBS
Message-ID: <5ec43d8916060d629b6adc9b9fff36ca@news.novabbs.com>
 by: minforth - Tue, 5 Dec 2023 08:40 UTC

Marsaglia XOR-shift Pseudo Random Number Generator

VARIABLE (RND) HERE (RND) ! ( dummy seed must not be zero )

1 CELLS 4 = [IF] 32-bit Forth
: RND ( -- r )
(RND) @
DUP 13 LSHIFT XOR
DUP 17 RSHIFT XOR
DUP 5 LSHIFT XOR
DUP (RND) ! ;

[ELSE] 64-bit Forth
: RND ( -- r )
(RND) @
DUP 13 LSHIFT XOR
DUP 7 RSHIFT XOR
DUP 17 LSHIFT XOR
DUP (RND) ! ;

[THEN]

Re: RANDOM routine pulled from an old paper

<07301104adbc906a95a6050fa771694e@news.novabbs.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=25325&group=comp.lang.forth#25325

  copy link   Newsgroups: comp.lang.forth
Date: Tue, 5 Dec 2023 11:04:21 +0000
Subject: Re: RANDOM routine pulled from an old paper
X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on novalink.us
From: mhx...@iae.nl (mhx)
Newsgroups: comp.lang.forth
X-Rslight-Site: $2y$10$8CYRQNPgH/3AckxY6u3.ieAchU0XGsLV0PIXhprPOOkdXOidy.93e
X-Rslight-Posting-User: 463cbf1a76c808942982a163321348c75477c065
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
User-Agent: Rocksolid Light
References: <810d6f56-e2dc-48f8-9a81-a06588cd7e44n@googlegroups.com> <34b422991a9d3a4896d3211dbd3827ca@news.novabbs.com> <5ec43d8916060d629b6adc9b9fff36ca@news.novabbs.com>
Organization: novaBBS
Message-ID: <07301104adbc906a95a6050fa771694e@news.novabbs.com>
 by: mhx - Tue, 5 Dec 2023 11:04 UTC

> VARIABLE (RND) HERE (RND) ! ( dummy seed must not be zero )

This will 'sporadically" fail on a transputer (signed addresses).

-marcel

Re: RANDOM routine pulled from an old paper

<65eddd46888b2908eabc5d4e638f7ed8@news.novabbs.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=25328&group=comp.lang.forth#25328

  copy link   Newsgroups: comp.lang.forth
Date: Tue, 5 Dec 2023 12:12:20 +0000
Subject: Re: RANDOM routine pulled from an old paper
X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on novalink.us
From: minfo...@gmx.net (minforth)
Newsgroups: comp.lang.forth
X-Rslight-Site: $2y$10$4Dlciy8wulhbGPC0JQcucOw8kclBfgw0CakRYzCEWQ/qmQkwuvCsi
X-Rslight-Posting-User: 0d6d33dbe0e2e1ff58b82acfc1a8a32ac3b1cb72
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
User-Agent: Rocksolid Light
References: <810d6f56-e2dc-48f8-9a81-a06588cd7e44n@googlegroups.com> <34b422991a9d3a4896d3211dbd3827ca@news.novabbs.com> <5ec43d8916060d629b6adc9b9fff36ca@news.novabbs.com> <07301104adbc906a95a6050fa771694e@news.novabbs.com>
Organization: novaBBS
Message-ID: <65eddd46888b2908eabc5d4e638f7ed8@news.novabbs.com>
 by: minforth - Tue, 5 Dec 2023 12:12 UTC

mhx wrote:
>> VARIABLE (RND) HERE (RND) ! ( dummy seed must not be zero )

> This will 'sporadically" fail on a transputer (signed addresses).

Your mulled wine must be especially good today! :o)

For even more mood enhancement:
https://www.sciencedirect.com/science/article/pii/S0377042718306265

Re: RANDOM routine pulled from an old paper

<nnd$50c9c506$5446bbc1@1e990a58aa14317d>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=25330&group=comp.lang.forth#25330

  copy link   Newsgroups: comp.lang.forth
Newsgroups: comp.lang.forth
Subject: Re: RANDOM routine pulled from an old paper
References: <810d6f56-e2dc-48f8-9a81-a06588cd7e44n@googlegroups.com> <34b422991a9d3a4896d3211dbd3827ca@news.novabbs.com> <5ec43d8916060d629b6adc9b9fff36ca@news.novabbs.com> <07301104adbc906a95a6050fa771694e@news.novabbs.com>
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
From: alb...@cherry (none)
Originator: albert@cherry.(none) (albert)
Message-ID: <nnd$50c9c506$5446bbc1@1e990a58aa14317d>
Organization: KPN B.V.
Date: Tue, 05 Dec 2023 13:48:24 +0100
Path: i2pn2.org!i2pn.org!news.1d4.us!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!feed.abavia.com!abe004.abavia.com!abp002.abavia.com!news.kpn.nl!not-for-mail
Lines: 16
Injection-Date: Tue, 05 Dec 2023 13:48:24 +0100
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
 by: none - Tue, 5 Dec 2023 12:48 UTC

In article <07301104adbc906a95a6050fa771694e@news.novabbs.com>,
mhx <mhx@iae.nl> wrote:
>> VARIABLE (RND) HERE (RND) ! ( dummy seed must not be zero )
>
>This will 'sporadically" fail on a transputer (signed addresses).

Easily fixed :
VARIABLE (RND) HERE 1+ (RND) ! ( dummy seed must not be zero )
>
>-marcel
--
Don't praise the day before the evening. One swallow doesn't make spring.
You must not say "hey" before you have crossed the bridge. Don't sell the
hide of the bear until you shot it. Better one bird in the hand than ten in
the air. First gain is a cat spinning. - the Wise from Antrim -

Re: RANDOM routine pulled from an old paper

<6a918d19c5cc39d58834497648705326@news.novabbs.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=25336&group=comp.lang.forth#25336

  copy link   Newsgroups: comp.lang.forth
Date: Tue, 5 Dec 2023 14:25:03 +0000
Subject: Re: RANDOM routine pulled from an old paper
X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on novalink.us
From: mhx...@iae.nl (mhx)
Newsgroups: comp.lang.forth
X-Rslight-Site: $2y$10$1sHBnmHdyJZwm.yjjasVFeiJOCJjbvvDuMjnVR/u8/KCvx5ZoPvrS
X-Rslight-Posting-User: 463cbf1a76c808942982a163321348c75477c065
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
User-Agent: Rocksolid Light
References: <810d6f56-e2dc-48f8-9a81-a06588cd7e44n@googlegroups.com> <34b422991a9d3a4896d3211dbd3827ca@news.novabbs.com> <5ec43d8916060d629b6adc9b9fff36ca@news.novabbs.com> <07301104adbc906a95a6050fa771694e@news.novabbs.com> <nnd$50c9c506$5446bbc1@1e990a58aa14317d>
Organization: novaBBS
Message-ID: <6a918d19c5cc39d58834497648705326@news.novabbs.com>
 by: mhx - Tue, 5 Dec 2023 14:25 UTC

none wrote:
[..]
>>This will 'sporadically" fail on a transputer (signed addresses).

> Easily fixed :
> VARIABLE (RND) HERE 1+ (RND) ! ( dummy seed must not be zero )

??

VARIABLE (RND) HERE 1 OR (RND) !
or
CREATE (RND) 1 ,

-marcel

Re: RANDOM routine pulled from an old paper

<uko9jn$dtag$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=25343&group=comp.lang.forth#25343

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!news.furie.org.uk!usenet.goja.nl.eu.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: dxfo...@gmail.com (dxf)
Newsgroups: comp.lang.forth
Subject: Re: RANDOM routine pulled from an old paper
Date: Wed, 6 Dec 2023 09:52:39 +1100
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <uko9jn$dtag$1@dont-email.me>
References: <810d6f56-e2dc-48f8-9a81-a06588cd7e44n@googlegroups.com>
<34b422991a9d3a4896d3211dbd3827ca@news.novabbs.com>
<5ec43d8916060d629b6adc9b9fff36ca@news.novabbs.com>
<07301104adbc906a95a6050fa771694e@news.novabbs.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 5 Dec 2023 22:52:40 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="7053b5ab584babb18db915e95c364f3a";
logging-data="456016"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+AIWyTc3WHUOfwjN3DAd4G"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:dmeIDQVDptfYBwmr788Oy/vg/RM=
In-Reply-To: <07301104adbc906a95a6050fa771694e@news.novabbs.com>
Content-Language: en-GB
 by: dxf - Tue, 5 Dec 2023 22:52 UTC

On 5/12/2023 10:04 pm, mhx wrote:
>> VARIABLE (RND) HERE (RND) ! ( dummy seed must not be zero )
>
> This will 'sporadically" fail on a transputer (signed addresses).

Presumably @EXECUTE and all routines that treat address 0 as a special
case would be problematic too? Perhaps it's a good thing transputers
are a forgotten technology remembered only by OT forthers :)

Re: RANDOM routine pulled from an old paper

<3cdd4162e4352b74bbd92967d389506c@news.novabbs.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=25344&group=comp.lang.forth#25344

  copy link   Newsgroups: comp.lang.forth
Date: Tue, 5 Dec 2023 23:34:25 +0000
Subject: Re: RANDOM routine pulled from an old paper
X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on novalink.us
From: mhx...@iae.nl (mhx)
Newsgroups: comp.lang.forth
X-Rslight-Site: $2y$10$j6HpsKGXzEOrWqDLwuCwO.pHuj.hgXg3rZE7ngoBO4X7UlrFUpviW
X-Rslight-Posting-User: 463cbf1a76c808942982a163321348c75477c065
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
User-Agent: Rocksolid Light
References: <810d6f56-e2dc-48f8-9a81-a06588cd7e44n@googlegroups.com> <34b422991a9d3a4896d3211dbd3827ca@news.novabbs.com> <5ec43d8916060d629b6adc9b9fff36ca@news.novabbs.com> <07301104adbc906a95a6050fa771694e@news.novabbs.com> <uko9jn$dtag$1@dont-email.me>
Organization: novaBBS
Message-ID: <3cdd4162e4352b74bbd92967d389506c@news.novabbs.com>
 by: mhx - Tue, 5 Dec 2023 23:34 UTC

dxf wrote:

> On 5/12/2023 10:04 pm, mhx wrote:
>>> VARIABLE (RND) HERE (RND) ! ( dummy seed must not be zero )
>>
>> This will 'sporadically" fail on a transputer (signed addresses).

> Presumably @EXECUTE and all routines that treat address 0 as a special
> case would be problematic too? Perhaps it's a good thing transputers
> are a forgotten technology remembered only by OT forthers :)

We noticed all that quite soon because some developers had a 16bit
transputer.

I rather like(d) the transputer ideas. Unfortunately, they failed to
deliver on their flagship T9000. On an overhead projector it was
10 times faster than an 80286.

-marcel


devel / comp.lang.forth / Re: RANDOM routine pulled from an old paper

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor