MathGroup Archive 2007

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

Search the Archive

Re: Riddle with Ordering

  • To: mathgroup at smc.vnet.net
  • Subject: [mg77934] Re: Riddle with Ordering
  • From: nazdrovje at gmail.com
  • Date: Wed, 20 Jun 2007 05:28:07 -0400 (EDT)
  • References: <f58dbg$8gi$1@smc.vnet.net>

I got this reply by  Andrzej Kozlowski, which was very close but not
what I intended.

****Begin quote

Iit's not much of a riddle for anyone who has been reading carefully
this forum for a while as it has turned up more than once.  It gives
you the permutation which will turn Sort[AnyList] into AnyList.   In
other words:

Sort[AnyList][[Ordering[Ordering[AnyList]]]] == Anylist


This means, in particular, that if AnyPermuation is any permutation:

Ordering[Ordering[AnyPermuation]]==AnyPermutation

Moreover, AnyList does not have to be a list of reals, or even a list
of numbers, and its elements need not be distinct.
*****End quote


The intended answer is that the above construct replaces each number
with its rank in the list. This is useful for all kinds of statistics
involving ranks, such as Spearman rank correlation (although
Mathematica has this already built-in). The reason I required the
numbers to be unique is that otherwise equal numbers would get unequal
(successive) ranks. Usually, a set of equal numbers is mapped to a set
of equal ranks (the average of the ranks that would be obtained for
the set by the above method).

Naz



On Jun 19, 1:06 pm, nazdro... at gmail.com wrote:
> Just a gem I discovered with Ordering[ ].
>
> Anyone have an idea what
>
> SomeArrayWithUniqueReals // Ordering // Ordering
>
> does?
>
> I like this, especially the double use of Ordering. Answer tomorrow.



  • Prev by Date: Re: Re: Re: A question about RegionFunction in ver. 6.0
  • Next by Date: ComplexExpand in Mathematica 5.2 and 6
  • Previous by thread: Re: Riddle with Ordering
  • Next by thread: Re: Re: Riddle with Ordering