From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.stack.nl!reality.xs3.de!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: Jacob Sparre Andersen Newsgroups: comp.lang.ada Subject: Re: Lotto simulation Date: Mon, 16 Jun 2014 16:25:51 +0200 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: <87oaxtvsls.fsf@adaheads.sparre-andersen.dk> References: <77cc4476-8c57-481b-afb9-8f53f8b16e37@googlegroups.com> NNTP-Posting-Host: monowall.adaheads.com Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: loke.gir.dk 1402929803 21238 86.48.41.195 (16 Jun 2014 14:43:23 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Mon, 16 Jun 2014 14:43:23 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) Cancel-Lock: sha1:aJ1o6rYUIUEF5CcsYmXJ34VVYbU= Xref: news.eternal-september.org comp.lang.ada:20365 Date: 2014-06-16T16:25:51+02:00 List-Id: Markus Schöpflin wrote: > The easiest way AFAIK is to random shuffle an integer array containing > the numbers 1 - 49 and then selecting the first six numbers from that > array. > > Random shuffling can be achieved by filling a second array of the same > size with random numbers obtained from a generator having a uniform > distribution and then sorting this second array; moving the numbers > from the first array in lock-step. Another option could be to fill one array: type Balls is range 1 .. 49; type Ordered_List_Of_Balls is array (Balls) of Balls; Ordered_Balls : Ordered_List_Of_Balls begin for Ball in Ordered_Balls'Range loop Ordered_Balls (Ball) := Ball; end loop; Then shuffle the balls in that array: for Primary in Ordered_Balls'Range loop Swap (List => Ordered_Balls, Position_1 => Primary, Position_2 => Random (Generator)); end loop; ... where I have assumed "sensible" declarations of Swap and Generator. Greetings, Jacob -- Statistics is like a bikini - what it shows is very suggestive, but the most important stuff is still hidden.