ArgMin and ArgMax

Revision as of 03:49, 26 April 2007 by ReneeB (talk | contribs) (adding doc status category)


Functions ArgMin and ArgMax

ArgMax(x, i) returns the value of index i for which array x is largest. More specifically, it returns a value, ix, of i, such that x[i =ix] = Max(x, i). Similarly, ArgMin(x, i) returns the value of i for which x is smallest. If there are ties (e.g., x has two identical values that are largest, it returns the one nearer the end of i.

ArgMin is new to Analytica 4.0.

Declaration

ArgMin( R : vector[I] ; I : ... optional IndexType ; position : optional boolean )
ArgMax( R : vector[I] ; I : ... optional IndexType ; position : optional boolean )

Single Index Usage

When ArgMin or ArgMax is used with a single index, as in the following usage

ArgMax( R:Car_prices, I:Car_type )

the value in index I is returned containing the extrema.


If array x has indexes in addition to i, Argmax(x, i) or Argmin(x, i) will return an array indexed by those indexes (not including i). For example, if x is indexed by i and j, it will return the value of i for which x is largest (or smallest) for each value of j.

Searching over Multiple Indexes

(new to 4.0)

If you want to find the smallest or largest value of x over more than one index, you can list all those indexes: e.g.

ArgMax(X, I: Mpg,Car_type )

It will then return an array dimensioned by a local index .Dim and any indexes of X that you did not list as parameters. Index .Dim will contain the names of the indexes given as parameters, Mpg and Car_type, in this case. The result will contain the values of Index Mpg and Car_type for which X is maximum (or minimum).

Positional Usage

By default, ArgMax (ArgMin) returns a value of the index. If you specify optional parameter position as true, they return the position of the value in the index for which x is maximum (minumum) -- a number. For example:

 ArgMax( R : Profit, I : UnitPrice, position : true )

This helps avoid ambiguity when the index contains duplicate values.

Related Functions

Comments


You are not allowed to post comments.