Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!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.020 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:question': 0.10; 'random': 0.14; 'correlation.': 0.16; 'iteration': 0.16; 'nodes': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'spurious': 0.16; 'wrote:': 0.18; 'module': 0.19; 'header:User- Agent:1': 0.23; 'header:X-Complaints-To:1': 0.27; 'header:In- Reply-To:1': 0.27; 'function': 0.29; 'fixed': 0.29; 'am,': 0.29; "i'm": 0.30; 'introducing': 0.36; 'sequence': 0.36; 'subject:Simple': 0.36; 'easiest': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'remove': 0.60; 'received:173': 0.61; 'visit': 0.64; 'different': 0.65; 'believe': 0.68; 'risk': 0.72; 'received:fios.verizon.net': 0.84; 'simulation': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Jan Reedy Subject: Re: Simple algorithm question - how to reorder a sequence economically Date: Fri, 24 May 2013 06:10:26 -0400 References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-173-75-251-66.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list 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: 13 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1369390242 news.xs4all.nl 15914 [2001:888:2000:d::a6]:43850 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:45874 On 5/24/2013 4:14 AM, Peter Brooks wrote: > What is the easiest way to reorder a sequence pseudo-randomly? > > That is, for a sequence 1,2,3,4 to produce an arbitrary ordering (eg > 2,1,4,3) that is different each time. > > I'm writing a simulation and would like to visit all the nodes in a > different order at each iteration of the simulation to remove the risk > of a fixed order introducing spurious evidence of correlation. random module has a shuffle function I believe