MathGroup Archive 2005

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

Search the Archive

Re: Maximum y-value in a list of xy pairs

  • To: mathgroup at smc.vnet.net
  • Subject: [mg61191] Re: [mg61124] Maximum y-value in a list of xy pairs
  • From: curtis <gardyloo at mail.wsu.edu>
  • Date: Wed, 12 Oct 2005 01:42:30 -0400 (EDT)
  • References: <200510110720.DAA14962@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Mike,
   Try

Needs["Statistics`DataManipulation`"]

pairs = {{0, 0.175}, {1, 0.54}, {2, 0.27}, {3, 0.47}, {4, 0.325}, {5, 0.527}, 

    {6, 0.22}, {7, 0.742}, {8, 0.109}, {9, 0.3314}, {10, 0.1481}}; 

Max[Column[pairs, 2]]


             Cheers,
                    C.O.

mike_in_england2000 at yahoo.co.uk wrote:

>Hi
>
>Is there an easy way of finding the maximum y-value of a list of x-y
>pairs?  For example:
>
>pairs = {{0, 0.175}, {1, 0.54}, {2, 0.27}, {3, 0.47}, {4, 0.325}, {5,
>      0.527}, {6, 0.22}, {7, 0.742}, {8, 0.109}, {9, 0.3314}, {10,
>0.1481}}
>
>Max[pairs] gives 10 which isnt what I want.  At the moment I am doing
>this:
>
>maxy = 0;
>Do[
>  currentx = pairs[[count]][[1]];
>  currenty = pairs[[count]][[2]];
>  If[currenty > maxy,
>    maxy = currenty;
>    x = currentx;
>    ];
>  , {count, 1, Length[pairs]}
>  ]
>Print[{x, maxy}]
>
>Which gives the maximum y value along with with its x-value but I
>suspect that there is a much more elegant way.  Any help would be
>appreciated.
>
>Thanks,
>
>Mike
>
>
>  
>

-- 
|=====
|  Curtis Osterhoudt              
|  gardyloo at mail.wsu.edu                   
|  PGP Key ID: 0x235FDED1                               
|  Please avoid sending me Word or PowerPoint attachments. 
|  http://www.gnu.org/philosophy/no-word-attachments.html 
|=====


  • Prev by Date: Re: Union using SameTest
  • Next by Date: Re: Skipping Elements in Sum
  • Previous by thread: Re: Maximum y-value in a list of xy pairs
  • Next by thread: Re: Maximum y-value in a list of xy pairs