Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: Random permutations [was Re: Libraries for sysadmins?] Date: Sat, 5 Mar 2016 13:46:13 -0500 Organization: A noiseless patient Spider Lines: 23 Message-ID: References: <2cec6af2-9636-4a2a-8849-b01286c0814c@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 5 Mar 2016 18:43:14 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="2d081e2f7155c28005d4472f67c2f43d"; logging-data="9636"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/P/OPyW1qAn0lzb17KCVfF" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 In-Reply-To: Cancel-Lock: sha1:S9NtLmtBPtHCFx0SDxA0rkdLFP0= Xref: csiph.com comp.lang.java.programmer:33934 On 3/5/2016 1:30 PM, Andreas Leitgeb wrote: > Sebastian wrote: >> Am 05.03.2016 12:11, schrieb Robert Klemme: >>> On 05.03.2016 00:56, Sebastian wrote: >>>> new Random().ints(1, 50).distinct().limit(6) >>> Are you sure this has the same probability characteristics as picking >>> six random items from a list of 49? >> I think yes, because Random#ints() is evenly distributed. > > Maybe similar enough for almost all practical purposes, but > strictly speaking, the distinct() might pass through a set > of less than 6 different ints. > > Anyone care to calculate the probability of that happening? > I'm too lazy (and my skill too rusty by now), to do it myself. Zero. However, the running time is (in principle) unbounded. -- esosman@comcast-dot-net.invalid "Don't be afraid of work. Make work afraid of you." -- TLM