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

Re: argMax

  • To: mathgroup at smc.vnet.net
  • Subject: [mg51270] Re: argMax
  • From: "Peltio" <peltio at twilight.zone>
  • Date: Mon, 11 Oct 2004 01:25:29 -0400 (EDT)
  • References: <ckaj3i$m3r$1@smc.vnet.net>
  • Reply-to: "Peltio" <peltioNOSP at Mdespammed.com.invalid>
  • Sender: owner-wri-mathgroup at wolfram.com

"Pierre Albarede" wrote

>I miss a fast internal function ArgMax.
[snip]
>but this will be much slower that Max. How can I have a faster argMax ?

I've written this without any testing, so I can't tell whether it's faster
or not than your solution (if it happens to be so, it won't be much faster,
though).
You can either have a version of ArgMax that works for onedimensional lists
giving you a list of the elements that produce a max (you can have more than
one)...

    ArgMax[f_, arglist_List] :=
      Module[
        {spectrum},
        spectrum = f /@ arglist;
        Flatten[Take[arglist, #] & /@ Position[spectrum, Max[spectrum]]]
    ]


Or a multidimensional one, that can give you a list of coordinates of the
points giving you a max.

    ArgMax[f_, arglist_List] :=
      Module[
        {spectrum},
        spectrum = Map[f, arglist, -1];
        Take[arglist, #] & /@ Position[spectrum, Max[spectrum]]
    ]

(pattern matching can be adopted to have the proc automatically choose the
code to be employed).

hope this helps,
Peltio
--
Invalid address in reply-to. Crafty demunging required to mail me.





  • Prev by Date: Outer product in mathematica
  • Next by Date: Re: plotting groups of polynomial roots
  • Previous by thread: argMax
  • Next by thread: Re: Re: argMax