Functions Min and Max

Revision as of 18:29, 18 May 2015 by Max (talk | contribs)


Functions Min and Max

Min(X, I)
Max(X, I)

Returns the smallest (Min) or largest (Max) value in array X over index I. You can use them to find the smallest or largest value over an explicit list of values enclosed in square brackets, in which case you omit the index:

Max([a, b, c])

This form evaluates a, b, and c, and finds the largest value among them. For example:

Max([Sin(30), Tan(30), Cos(30)]) --> 0.8660254

Although index I is optional, we strongly recommend you include it even if X currently only has one index. You might expand the model so that X gets another index, J: Then Min(X) would be ambiguous. Analytica couldn't tell whether you meant Min(X, I) or Min(X, J), and might not interpret it the way you want.

If X contains text values, it returns the first (Min) or last (Max) value in alphabetic order. If X contains mixed text and numbers, it treats text before or "smaller than" numbers. Thus,

Min(['A', 'B', 2]) &rarr 'A'
Max(['A', 'B', 2]) &rarr  2

It orders text as case sensitive unless you specify otherwise with the optional CaseSensitive parameter (see below).

Optional Parameters

Multiple Indexes

Min(X, I, J, K, ...)
Min(X, I, J, K, ...)

You can specify more than one index, e.g., Max(X, I, J) is equivalent to Max(Max(X, I), J). This finds the maximum or minimum over all the specified indexes of X.

Non-Numerics

Min(X, I, IgnoreNonNumerics, IgnoreNaN)
Max(X, I, IgnoreNonNumerics, IgnoreNaN)

If IgnoreNonNumerics is set to true (1), it ignores non-numeric values. If IgnoreNAN is set to true (1), it ignores NAN values. It always ignores NULL no matter what the parameter values. These optional Boolean parameters require a named-parameter syntax.

I → 1 2 3 4 5 6 7
A → 56 "a" 4 "1" 3 «null» 45
Min(A, I, IgnoreNonNumerics: True) &rarr 3
Max(A, I, IgnoreNonNumerics: True) &rarr 56

A NaN value occurs when an arithmetic operation is indeterminate, such as the result of a divide by zero. These are would-be numeric values, but just indeterminate, so the result of a Min or Max on NaN is also NaN. These normally propagate so that you don't get misleading results downstream, but if you also want to ignore NaN values, then include «IgnoreNaN» set to true.

Case Insensitivity

Comparison of text values by Min and Max is done in a case-sensitive fashion by default. You can specify the optional «caseInsensitive» parameter as true to do the comparison in a case-insensitive manner, e.g.:

Min(['DeBois', 'Debbie', 'Debutante' ]) → 'DeBois'
Min(['DeBois', 'Debbie', 'Debutante' ], CaseInsensitive: True) → 'Debbie'

Functions CondMin and CondMax

CondMin(X: Array[I]; cond: Boolean[I];  I: Index)
CondMax(X: Array[I]; cond: Boolean[I];  I: Index)

Conditional Min and Max. These return the smallest (CondMin) or largest (CondMax) values along a given index, but only along a subset of values as indicated by the parameter cond.

When no cell satisfies «cond», the result of CondMax is -INF, and the result of CondMin is INF.

Starting with 4.4, CondMax and CondMin support the named parameter syntax and allow multiple indexes to be listed. The optional flag parameter «caseInsensitive» can be set to true (default is False).

Related Functions

Comments


You are not allowed to post comments.