Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Richard Ashbery Newsgroups: comp.sys.acorn.programmer Subject: Re: Specific numbers but in a random sequence Date: Sat, 22 Jun 2019 16:46:35 +0100 Organization: None Lines: 56 Message-ID: <57c82fa1bdbasura@invalid.addr.uk> References: <57c7c5d6c0basura@invalid.addr.uk> X-Trace: individual.net wnqFjUTzBDXMShvGP1inhQnto1iSe5DvRbxjbncAVHXskwZ52C X-Orig-Path: uwclub.net!richard.ashbery Cancel-Lock: sha1:FgjmxLmN+85wBWHGmILQYPO+68E= User-Agent: Pluto/3.16 (RISC OS/5.25) NewsHound/v1.52-32 Xref: csiph.com comp.sys.acorn.programmer:5774 In article , druck wrote: > On 21/06/2019 22:27, Gavin Crawford wrote: > > Richard Ashbery 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