Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

argMax

  • To: mathgroup at smc.vnet.net
  • Subject: [mg51243] argMax
  • From: Pierre Albarede <pa.news at free.fr>
  • Date: Sun, 10 Oct 2004 01:57:14 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

I miss a fast internal function ArgMax. Sure, it is easily programmed, 
for example,

argMaxMax[function1_, list1_List] := With[
{max1 = Max[function1 /@ list1]},
{Select[list1, function1[#] == max1 &], max1}
]

argMax = Composition[First, argMaxMax]

or

argMaxMax1[function1_, list1_List] := With[
{h = MapIndexed[{function1@#1, #2} &, list1]},
With[
{max1 = Max[First /@ h]},
{Extract[list1, Last /@ Select[h, First@# == max1 &]], max1}
]
]

argMax = Composition[First, argMaxMax1]

but this will be much slower that Max. How can I have a faster argMax ?

Thanks.


  • Prev by Date: Re: suggestion for frontend
  • Next by Date: Re: suggestion for frontend
  • Previous by thread: Re: Generating r-combination or r-permutations with replacement.
  • Next by thread: Re: argMax