MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: shuffling (randomizing) a series

  • To: mathgroup at
  • Subject: [mg52894] Re: [mg52857] shuffling (randomizing) a series
  • From: "Caffa Vittorio Dr." <Caffa at>
  • Date: Thu, 16 Dec 2004 03:40:28 -0500 (EST)
  • Sender: owner-wri-mathgroup at

Try this:

In[1]:= << DiscreteMath`Combinatorica`

In[2]:= Shuffle[l_List] := l[[RandomPermutation[Length[l]]]]

In[3]:= Shuffle[Range[11, 20]]

Out[3]= {17, 16, 11, 12, 14, 20, 18, 15, 19, 13}

In[4]:= data = Range[10^7] 0.001;

In[5]:= {t, newdata} = Timing[Shuffle[data]];

In[6]:= Take[newdata, 5]

Out[6]= {724.918, 8752.08, 3601.98, 2687.99, 5986.51}

In[7]:= t

Out[7]= 19.227 Second

Cheers, Vittorio

-----Original Message-----
From: George Szpiro [mailto:george at] 
To: mathgroup at
Subject: [mg52894] [mg52857] shuffling (randomizing) a series


I would like to put a series of numbers (of the order of 10^7 numbers) into 
random order, i.e., to shuffle it. In Excel I would simply add a column next 
to the column with the data, and then sort by the random number. But I could 
only do this for 64000 numbers. How can I do that in Mathematica for a file with a 
much larger series?

(could you please copy any answer to my address:
george at



George Szpiro
Neue Zürcher Zeitung (Switzerland)
POB 6278
Jerusalem 91060

  • Prev by Date: plotting two functions on the one graph
  • Next by Date: NIntegrate a list
  • Previous by thread: Re: shuffling (randomizing) a series
  • Next by thread: Reverse Hash Function