MathGroup Archive 2000

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

Search the Archive

Re: how to rank a list of elements?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg23198] Re: how to rank a list of elements?
  • From: d8442803 at student.nsysu.edu.tw (Wen-Feng Hsiao)
  • Date: Mon, 24 Apr 2000 01:12:06 -0400 (EDT)
  • Organization: NSYSU
  • References: <8djk08$7dc@smc.vnet.net> <8dnuge$hrl@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

On Thu, 20 Apr 2000 08:51:23 +0200
Hartmut Wolf <hwolf at debis.com> wrote:

> Dear Wen-Feng,
> 
> Since you didn't state your problem but only a solution, it's hard to
> guess. (It would have been helpful to have stated the "real world
> problem"; often the mapping of that to the mathematical model -- or
> object model for programming -- is the most decisive step to a
> solution.)
> 
> Anyways, you have to answer yourself the question: why not have
> 
> 	{4, 2, 3, 1} or
> 	{3, 2, 3, 1} or even
> 	{{3, 4}, 2, {3, 4}, 1} or 
> 	{{3, 4}, 2, see[1], 1}
> 
> as a result?? (It also depends on what you intend to do with it.)
My question is quite simple, just "to rank a list of elements (scores)".
This is a common situation when the obtained scores are not reliable to
be an interval scale, the usual procedure is to transform them into an
ordinal scale before conducting statistical analyses. For example, in an 
IQ
test, we obtain the following scores:
{107, 110, 110, 120, 125, 125, 125, 136}
, which can be ranked as

{1., 2.5, 2.5, 4., 6., 6., 6., 8.}, if we use 'mean' to deal with ties;
or
{1., 2., 2., 4., 5., 5., 5., 8.}, if we use 'min' to deal with ties;
or
{1., 3., 3., 4., 7., 7., 7., 8.}, if we use 'max' to deal with ties.

By intuition, same scores should have same ranks. However, your
illustrations are, though sophisticated, not consistent with this
intuition. Allan Hayes's code is more likely as what I want. From his
code I know I can use 'Rule' to get what I want: (Please correct me if
anything needs to be improved.)

<< Statistics`
(* ties = -1, low; ties = 0, mean; ties = 1, high *)
ranking[datalst_List, ties_:0] := Module[{ratings, posset, substitutes},
      methods = {Min, Mean, Max};
      posset = 
        Position[Sort[datalst], #] & /@ Sort[datalst] /. {lst_} -> lst;
      ratings = methods[[ties + 2]][#] & /@ posset // N;
      substitutes = Apply[Rule, Transpose[{Sort[datalst], ratings}], 
{1}];
      Print[substitutes];
      Return[datalst /. substitutes];
      ];

In[74]:=
ranking[dataset]
Out[74]=
{1., 2.5, 2.5, 4., 6., 6., 6., 8.}

In[75]:=
ranking[dataset, -1]
Out[75]=
{1., 2., 2., 4., 5., 5., 5., 8.}

In[76]:=
ranking[dataset, 1]
Out[76]=
{1., 3., 3., 4., 7., 7., 7., 8.}

Wen-Feng


  • Prev by Date: RE: output from a package
  • Next by Date: Re: Help, my MathLink Examples segfault.
  • Previous by thread: Re: how to rank a list of elements?
  • Next by thread: Re: Re: how to rank a list of elements?