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!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Lotto simulation Date: Sun, 15 Jun 2014 21:54:33 +0100 Organization: A noiseless patient Spider Message-ID: References: <77cc4476-8c57-481b-afb9-8f53f8b16e37@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx05.eternal-september.org; posting-host="a4a86ddfabe7a860897511d47e5acc83"; logging-data="26956"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19AKR5WqEizXqb4S0LKudBIzGIQ0x0pexI=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (darwin) Cancel-Lock: sha1:xmUtzyqtabEdj4+F6dPcsn7ZvOI= sha1:AauYSA+UrdRjR0siDnnYkikUldw= Xref: news.eternal-september.org comp.lang.ada:20332 Date: 2014-06-15T21:54:33+01:00 List-Id: montgrimpulo writes: > A workaround would be to test in each round, if that number has > already been selected. However, the probability would not be the same > as with a reduced set as the selection would be always from the full > set. This seems perfectly reasonable. If you think of numbered balls like the UK lottery, and after each pick replace the picked ball by one without a number. By the time you get to the last 2 numbered balls, each of them has a 50% chance of being the one that's eventually picked, no matter how many times you discard unnumbered balls. Depending on the RNG, of course. Another possibility: create an array of {ball-number, random-float}, sort by the random-float component, choose the first N entries.