MathGroup Archive 2007

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

Search the Archive

Re: Coding an inverse permutation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg79141] Re: Coding an inverse permutation
  • From: "Dana DeLouis" <dana.del at gmail.com>
  • Date: Thu, 19 Jul 2007 03:39:19 -0400 (EDT)

> I want to figure out a clean way to code its inverse permutation.
> The inverse permutation list would start as follows:
> bb={1,2,4,5,3,10,8,6, ...}

Hi.  Just 2 cents....

Needs["Combinatorica`"]

aa = {1, 2, 5, 3, 4, 8, 9, 7, <<snip>> , 97, 72, 82, 91, 87}; 

Is this a "Permutation" ?

PermutationQ[aa]
False

No.  Otherwise you could use InversePermutation[aa]

I don't think what you want will work because your list is not a
Permutation.
For example, when you get to 97 in your list, there is no position 97, since
your list is only 88 long.  Therefore, there is a logic error in your
request.

{Length[aa], Max[aa]}

{88, 97}

Your permutation is missing the following numbers:

missing = Complement[Range[Max[aa]], aa]

{78, 84, 86, 88, 90, 92, 93, 94, 96}

-- 
HTH   :>)
Dana DeLouis
Windows XP & Mathematica 6.0.1


"Diana" <diana.mecum at gmail.com> wrote in message
news:f7kdht$49n$1 at smc.vnet.net...
> Folks,
> 
> I have the following list:
> 
> aa={1, 2, 5, 3, 4, 8, 9, 7, 11, 6, 13, 17, 10, 16, 19, 15, 14, 20, 21,
> 23, 25, 12, 29, 31, 18, 22,
> 37, 27, 26, 28, 33, 35, 32, 24, 41, 43, 30, 34, 47, 39, 38, 40, 45,
> 49, 44, 36, 53, 55, 46, 52,
> 59, 51, 50, 56, 57, 61, 62, 42, 67, 71, 48, 58, 65, 63, 64, 68, 69,
> 73, 74, 54, 77, 79, 60, 76,
> 83, 75, 80, 70, 81, 89, 85, 66, 95, 97, 72, 82, 91, 87}
> 
> I want to figure out a clean way to code its inverse permutation.
> 
> The inverse permutation list would start as follows:
> 
> bb={1,2,4,5,3,10,8,6, ...}
> 
> Since "3" is in position 4 of aa, position 3 of bb will be "4".
> Since "5" is in position 3 of aa, position 5 of bb will be "3".
> 
> Can someone give me a suggestion as to how to code this?
> 
> Thanks, Diana



  • Prev by Date: Re: Coding an inverse permutation
  • Next by Date: Re: generating non-IID random sequences
  • Previous by thread: Re: Coding an inverse permutation
  • Next by thread: Re: Coding an inverse permutation