Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.acorn.programmer > #5783

Re: Specific numbers but in a random sequence

From Paul Oates <oatespaul@btinternet.com>
Newsgroups comp.sys.acorn.programmer
Subject Re: Specific numbers but in a random sequence
Date 2019-06-23 13:17 +0100
Organization Aioe.org NNTP Server
Message-ID <0f5da0c857.Paul@oatespaul.btinternet.com> (permalink)
References (4 earlier) <qeljvl$1i81$1@gioia.aioe.org> <57c8384f3bbasura@invalid.addr.uk> <mpro.ptiowz0137v62032t.news@stevefryatt.org.uk> <57c8955578basura@invalid.addr.uk> <20190623120736.3390b842@ian-460-p050na>

Show all headers | View raw


In message <20190623120736.3390b842@ian-460-p050na>
          Ian <Ian.Hamilton@AAUG.net> wrote:

> On Sun, 23 Jun 2019 11:17:26 +0100
> Richard Ashbery <basura@invalid.addr.uk> wrote:

>> In article <mpro.ptiowz0137v62032t.news@stevefryatt.org.uk>,
>>    Steve Fryatt <news@stevefryatt.org.uk> wrote:
>>> On 22 Jun, Richard Ashbery wrote in message
>>>     <57c8384f3bbasura@invalid.addr.uk>:
>> 
>>>> RND(500)MOD18 for example appears to improve the distribution.
>>>> How can I incorporate this idea with my 18 specific numbers in
>>>> the array?
>> 
>>> You don't need to. Just do this:
>> 
>>> DIM array%(18)
>>> array%() = 3,4,5,6,8,9,10,12,15,18,20,24,30,36,45,60,90,120
>>> y = RND(-TIME)
>>> FOR loop = 1 TO 5
>>> FOR I% = 0 TO 18
>>> PRINT array%(RND(18))
>>> NEXT I%
>>> NEXT loop
>> 
>> That's pretty much what I eventually arrived at. RND(18) makes other
>> variables appear in a more random distribution as other respondents
>> have pointed out earlier. There's only one problem which makes no
>> sense to me in that 3 never appears but 0 does.
>> 
>> Can others confirm please?
>> 


> The array%() is being initialised from (0) to (17). (18) would contain
> the zero. (0) contains the three.

> Random numbers are 1 to 18. So three doesn't appear, zero does.

> Add '0,' so that array%()=0,3,4,5,6,8 etc. and it should work.

> I haven't tested it.

> HTH,
> Ian

The array has 18 items, but the FOR...NEXT loop has 19. Perhaps it would 
be as well to test the program by commenting out the 'PRINT array% 
(RND(18))' and inserting 'PRINT loop, I%'. (just out of interest why is 
'loop' not an Integer variable like I%?). Then when you are happy that the 
loops are working you could revert. If you wanted, as an interim step 
after testing the loops, you could replace '(RND(18))' with '(I%)' to 
ensure all the entries in the array are produced.

regards

-- 
Paul Oates
oatespaul@btinternet.com

Back to comp.sys.acorn.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Specific numbers but in a random sequence Richard Ashbery <basura@invalid.addr.uk> - 2019-06-21 21:31 +0100
  Re:Specific numbers but in a random sequence Gavin Crawford <gc@dentrassis.com> - 2019-06-21 22:27 +0100
    Re: Specific numbers but in a random sequence druck <news@druck.org.uk> - 2019-06-22 11:48 +0100
      Re: Specific numbers but in a random sequence Richard Ashbery <basura@invalid.addr.uk> - 2019-06-22 12:03 +0100
      Re: Specific numbers but in a random sequence Richard Ashbery <basura@invalid.addr.uk> - 2019-06-22 16:46 +0100
        Re: Specific numbers but in a random sequence Someone Somewhere <nntpac@gmail.com> - 2019-06-22 17:11 +0100
          Re: Specific numbers but in a random sequence Richard Ashbery <basura@invalid.addr.uk> - 2019-06-22 18:21 +0100
            Re: Specific numbers but in a random sequence Steve Fryatt <news@stevefryatt.org.uk> - 2019-06-22 21:29 +0100
              Re: Specific numbers but in a random sequence Richard Ashbery <basura@invalid.addr.uk> - 2019-06-23 11:17 +0100
                Re: Specific numbers but in a random sequence Ian <Ian.Hamilton@AAUG.net> - 2019-06-23 12:07 +0100
                Re: Specific numbers but in a random sequence Paul Oates <oatespaul@btinternet.com> - 2019-06-23 13:17 +0100
                Re: Specific numbers but in a random sequence Steve Fryatt <news@stevefryatt.org.uk> - 2019-06-23 13:51 +0100
                Re: Specific numbers but in a random sequence Richard Ashbery <basura@invalid.addr.uk> - 2019-06-23 14:10 +0100
                Re: Specific numbers but in a random sequence Steve Fryatt <news@stevefryatt.org.uk> - 2019-06-23 15:59 +0100
                Re: Specific numbers but in a random sequence Richard Ashbery <basura@invalid.addr.uk> - 2019-06-23 17:14 +0100
                Re: Specific numbers but in a random sequence Richard Ashbery <basura@invalid.addr.uk> - 2019-06-23 14:01 +0100
        Re: Specific numbers but in a random sequence Paul Oates <oatespaul@btinternet.com> - 2019-06-22 17:52 +0100
        Re: Specific numbers but in a random sequence Julian Fry <julianfry@orpheusmail.co.uk> - 2019-06-22 17:56 +0100
        Re: Specific numbers but in a random sequence Julian Fry <JulianFry@compuserve.com> - 2019-06-22 18:05 +0100
  Re: Specific numbers but in a random sequence Sebastian Barthel <naitsabes@freenet.de> - 2019-06-24 07:37 +0000
    Re: Specific numbers but in a random sequence Richard Ashbery <basura@invalid.addr.uk> - 2019-06-24 20:13 +0100

csiph-web