Re: Quick Question
- To: mathgroup at smc.vnet.net
- Subject: [mg78131] Re: [mg78090] Quick Question
- From: Carl Woll <carlw at wolfram.com>
- Date: Sat, 23 Jun 2007 07:17:25 -0400 (EDT)
- References: <200706221050.GAA16639@smc.vnet.net>
rob cronin wrote:
>Quick Question:
>
>With Mathematica 5.2 is there any way to scramble a simple list of numbers:
>i.e. randomly rearange the list {1,2,3,4,5,6} without any apparent order.
>
>Kind regards
>
>_________________________________________________________________
>Get a preview of Live Earth, the hottest event this summer - only on MSN
>http://liveearth.msn.com?source=msntaglineliveearthhm
>
>
>
You could look up RandomPermutation in DiscreteMath`Combinatorica`
<<DiscreteMath`Combinatorica`
RandomPermutation[6]
Or, you could create your own permutation function:
randomperm[data_] := data[[ Ordering[ Table[Random[], {Length[data]}] ] ]]
list={1,2,3,4,5,6}
In[9]:=
randomperm[Range[6]]
Out[9]=
{6,4,1,5,2,3}
Carl Woll
Wolfram Research
- References:
- Quick Question
- From: "rob cronin" <cronin_rob@hotmail.com>
- Quick Question