Re: Simple algorithm question - how to reorder a sequence economically

2013-06-12 Thread Robert Kern
On 2013-05-24 14:43, Chris Angelico wrote: On Fri, May 24, 2013 at 11:23 PM, Peter Brooks wrote: Actually, thinking about it, there is probably a source of non-algorithmically-derived 'random' numbers somewhere on the net that would do the job nicely. True entropy is usually provided by a sou

RE: Simple algorithm question - how to reorder a sequence economically

2013-06-12 Thread Carlos Nepomuceno
> Date: Fri, 24 May 2013 17:28:07 -0700 > Subject: Re: Simple algorithm question - how to reorder a sequence > economically > From: peter.h.m.bro...@gmail.com > To: python-list@python.org [...] > If the scenario could be modelled ma

Re: Simple algorithm question - how to reorder a sequence economically

2013-06-12 Thread Chris Angelico
On Fri, May 24, 2013 at 11:23 PM, Peter Brooks wrote: > Actually, thinking about > it, there is probably a source of non-algorithmically-derived 'random' > numbers somewhere on the net that would do the job nicely. True entropy is usually provided by a source such as /dev/random (on Unix systems)

Re: Simple algorithm question - how to reorder a sequence economically

2013-06-12 Thread Dave Angel
On 05/25/2013 09:49 PM, Roy Smith wrote: In article <15a1bb3a-514c-454e-a966-243c84123...@googlegroups.com>, John Ladasky wrote: Because someone's got to say it... "The generation of random numbers is too important to be left to chance." ‹ Robert R. Coveyou Absolutely. I know just enough

Re: Simple algorithm question - how to reorder a sequence economically

2013-05-25 Thread Roy Smith
In article <15a1bb3a-514c-454e-a966-243c84123...@googlegroups.com>, John Ladasky wrote: > Because someone's got to say it... "The generation of random numbers is too > important to be left to chance." ‹ Robert R. Coveyou Absolutely. I know just enough about random number generation to unders

Re: Simple algorithm question - how to reorder a sequence economically

2013-05-25 Thread John Ladasky
On Friday, May 24, 2013 10:33:47 AM UTC-7, Yours Truly wrote: > If you don't reshuffle p, it guarantees the maximum interval between reusing > the same permutation. Of course, that comes at a certain price. Given two permutations p[x] and p[x+1], they will ALWAYS be adjacent, in every repetition

Re: Simple algorithm question - how to reorder a sequence economically

2013-05-24 Thread Peter Brooks
On May 24, 11:33 pm, Carlos Nepomuceno wrote: > > > > > > > > > > > > Date: Fri, 24 May 2013 12:01:35 -0700 > > Subject: Re: Simple algorithm question - how to reorder a sequence > > economically >

RE: Simple algorithm question - how to reorder a sequence economically

2013-05-24 Thread Carlos Nepomuceno
> Date: Fri, 24 May 2013 12:01:35 -0700 > Subject: Re: Simple algorithm question - how to reorder a sequence > economically > From: peter.h.m.bro...@gmail.com > To: python-list@python.org > > On May 24, 5:00 pm, Carlos Nepomuceno >

Re: Simple algorithm question - how to reorder a sequence economically

2013-05-24 Thread Peter Brooks
On May 24, 5:00 pm, Carlos Nepomuceno wrote: > > > I don't know what "spurious evidence of correlation" is. Can you give a > mathematical definition? > If I run the simulation with the same sequence, then, because event E1 always comes before event E2, somebody might believe that there is a causa

Re: Simple algorithm question - how to reorder a sequence economically

2013-05-24 Thread John Ladasky
On Friday, May 24, 2013 3:52:18 AM UTC-7, Steven D'Aprano wrote: > On Fri, 24 May 2013 01:14:45 -0700, Peter Brooks wrote: > > > That is, for a sequence 1,2,3,4 to produce an arbitrary ordering (eg > > 2,1,4,3) that is different each time. > > You can't *guarantee* that it will be different each

RE: Simple algorithm question - how to reorder a sequence economically

2013-05-24 Thread Carlos Nepomuceno
> Date: Fri, 24 May 2013 01:14:45 -0700 > Subject: Simple algorithm question - how to reorder a sequence economically > From: peter.h.m.bro...@gmail.com > To: python-list@python.org > > What is the easiest way to reorder a sequence pseudo-

Re: Simple algorithm question - how to reorder a sequence economically

2013-05-24 Thread duncan smith
On 24/05/13 10:11, Chris Angelico wrote: On Fri, May 24, 2013 at 6:47 PM, Fábio Santos wrote: On 24 May 2013 09:41, "Chris Angelico" wrote: On Fri, May 24, 2013 at 6:14 PM, Peter Brooks wrote: What is the easiest way to reorder a sequence pseudo-randomly? That is, for a sequence 1,2,3,4

Re: Simple algorithm question - how to reorder a sequence economically

2013-05-24 Thread Steven D'Aprano
On Fri, 24 May 2013 06:23:14 -0700, Peter Brooks wrote: > Thanks for the warnings about random numbers too - I hope my lists will > be short enough for the permutations of the function to be irrelevant. I > don't need every single sequence to be unique, only that the same > sequence only occurs o

Re: Simple algorithm question - how to reorder a sequence economically

2013-05-24 Thread Peter Brooks
Thank you all for those most helpful suggestions! random.shuffle does precisely the job that I need quickly. Thank you for introducing me to itertools, though, I should have remembered APL did this in a symbol or two and I'm sure that itertools will come in handy in future. Thanks for the warnings

Re: Simple algorithm question - how to reorder a sequence economically

2013-05-24 Thread Ned Batchelder
On 5/24/2013 6:52 AM, Steven D'Aprano wrote: On Fri, 24 May 2013 01:14:45 -0700, Peter Brooks wrote: What is the easiest way to reorder a sequence pseudo-randomly? import random random.shuffle(sequence) The sequence is modified in place, so it must be mutable. Lists are okay, tuples are not.

Re: Simple algorithm question - how to reorder a sequence economically

2013-05-24 Thread Steven D'Aprano
On Fri, 24 May 2013 01:14:45 -0700, Peter Brooks wrote: > What is the easiest way to reorder a sequence pseudo-randomly? import random random.shuffle(sequence) The sequence is modified in place, so it must be mutable. Lists are okay, tuples are not. > That is, for a sequence 1,2,3,4 to produ

Re: Simple algorithm question - how to reorder a sequence economically

2013-05-24 Thread Terry Jan Reedy
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

Re: Simple algorithm question - how to reorder a sequence economically

2013-05-24 Thread Chris Angelico
On Fri, May 24, 2013 at 6:47 PM, Fábio Santos wrote: > > On 24 May 2013 09:41, "Chris Angelico" wrote: >> >> On Fri, May 24, 2013 at 6:14 PM, 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 arbitra

Re: Simple algorithm question - how to reorder a sequence economically

2013-05-24 Thread Fábio Santos
On 24 May 2013 09:41, "Chris Angelico" wrote: > > On Fri, May 24, 2013 at 6:14 PM, 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. > > ..

Re: Simple algorithm question - how to reorder a sequence economically

2013-05-24 Thread Chris Angelico
On Fri, May 24, 2013 at 6:14 PM, 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

Simple algorithm question - how to reorder a sequence economically

2013-05-24 Thread Peter Brooks
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 remo