ArgMin and ArgMax

(Redirected from ArgMin)


4.6  •  5.0  •  5.1  •  5.2  •  5.3  •  5.4  •  6.0  •  6.1  •  6.2  •  6.3  •  6.4  •  6.5

ArgMax(r, i, position, first), ArgMin(r, i, position, first)

ArgMax(r, i) returns the value of index «i» for which array «r» contains the largest numerical value (or if «r» contains text, the last in alphabetic order.) More specifically, it returns a value, ix where r[i = ix] = Max(r, i). If there are ties, i.e. «r» has two or more values that are equal largest, it returns the value of «i» nearest the end. Similarly, ArgMin(r, i) returns the value of «i» for which «r» is smallest (or if «r» contains text, the first alphabetically.)

Optional flags:

  • position: (default:false) When true, it returns the index position -- 1 when the max or min appears in the first element.
  • first: (default:false) If True, it returns first position (rather than the default last when there are ties.

Use with multiple indexes

ArgMax(r, i) and ArgMin(r, i) expect «r» to be an array with index i, and return a result not indexed by i. If array «r» has any indexes in addition to «i», the result will retain those other indexes. For example, if «r» is indexed by «i» and j, it will return the value of «i» for which «r» is largest (or smallest) for each value of j.

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 and ArgMin return a value of the index. If you specify optional parameter «position» as True, they return the position instead of the value of the index containing the maximum (minimum). For example:

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

This helps avoid ambiguity when the index contains duplicate values.


The «first» attrribute was introduced in Analytica 5.2.

See Also


You are not allowed to post comments.