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


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

Re: Specific numbers but in a random sequence

From Richard Ashbery <basura@invalid.addr.uk>
Newsgroups comp.sys.acorn.programmer
Subject Re: Specific numbers but in a random sequence
Date 2019-06-22 16:46 +0100
Organization None
Message-ID <57c82fa1bdbasura@invalid.addr.uk> (permalink)
References <57c7c5d6c0basura@invalid.addr.uk> <qeji40$7ca$1@dont-email.me> <qel12p$ibq$1@dont-email.me>

Show all headers | View raw


In article <qel12p$ibq$1@dont-email.me>,
   druck <news@druck.org.uk> wrote:
> On 21/06/2019 22:27, Gavin Crawford wrote:
> > Richard Ashbery <basura@invalid.addr.uk> Wrote in message:

[snip]

3,4,5,6,8,9,10,12,15,18,20,24,30,36,45,60,90,120I would like to be
able to use these variables in a random sequence.

> > Why not put them into an array and use a random number to choose
> >   the array index.

> Yes, and make sure you seed the random number generator, or it may 
> always go through the same pseudo random sequence each time its run.

> IIRC to seed do RND(-TIME) before any other call to RND.

Not quite there yet - if I use the following...

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(I%))
NEXT I%
NEXT loop

90 random numbers gives poor distribution:

3 x10
4 x14
5 x16
6 x8
8 x9
9 x4
10 x6
12 x3
15 x2
18 x3
20 x7
24 x7
30 x2
36 none
45 none
60 x2
90 none
120 x1

5 is repeated 3 times in a row. 

Is there any way of improving it?

Richard

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