Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.028 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'repeated': 0.07; 'satisfy': 0.09; 'second.': 0.09; 'resulting': 0.13; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'roy': 0.16; 'subject:sample': 0.16; 'values:': 0.16; 'wrote:': 0.17; 'items.': 0.17; 'typical': 0.17; 'sets': 0.23; 'split': 0.23; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'received:192.168.1.3': 0.29; 'way?': 0.29; 'to:addr:python-list': 0.33; 'list': 0.35; 'subject:?': 0.35; 'there': 0.35; 'but': 0.36; '(i.e.': 0.36; 'should': 0.36; 'item': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'sure': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'first': 0.61; 'between': 0.63; 'more': 0.63; 'header:Reply-To:1': 0.68; 'smith': 0.71; 'reply-to:no real name:2**0': 0.72; 'reply- to:addr:python.org': 0.84; '100,000': 0.91 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.0 cv=XeZXOvF5 c=1 sm=1 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=Tv4_tr9OjFAA:10 a=DAMK9_AKRX4A:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=9Ng8dtFq3VsA:10 a=vhbaPsquHVjvQsKVlOkA:9 a=wPNLvfGTeEIA:10 a=0nF1XD0wxitMEM03M9B4ZQ==:117 X-AUTH: mrabarnett:2500 Date: Fri, 11 Jan 2013 14:36:57 +0000 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130107 Thunderbird/17.0.2 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Multiple disjoint sample sets? References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: python-list@python.org List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1357915022 news.xs4all.nl 6939 [2001:888:2000:d::a6]:58293 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:36625 On 2013-01-11 14:15, Roy Smith wrote: > I have a list of items. I need to generate n samples of k unique items > each. I not only want each sample set to have no repeats, but I also > want to make sure the sets are disjoint (i.e. no item repeated between > sets). > > random.sample(items, k) will satisfy the first constraint, but not the > second. Should I just do random.sample(items, k*n), and then split the > resulting big list into n pieces? Or is there some more efficient way? > > Typical values: > > len(items) = 5,000,000 > n = 10 > k = 100,000 > I don't know how efficient it would be, but couldn't you shuffle the list and then use slicing to get the samples?