Functions Min and Max


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

Return 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]) → 'A'
Max(['A', 'B', 2]) → 2

It orders text as case sensitive unless you specify otherwise with the optional «CaseInsensitive» 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».

IgnoreNonNumerics and IgnoreNAN

These optional Boolean parameters require a named-parameter syntax. 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.

Variable A :=
I ▶
1 2 3 4 5 6 7
56 "a" 4 "1" 3 «null» 45
Min(A, I, IgnoreNonNumerics: True) → 3
Max(A, I, IgnoreNonNumerics: True) → 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.

CaseInsensitive

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'

CondMin(X, cond, I), CondMax(X, cond, I)

Syntax

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 Analytica 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).

See Also

Comments


You are not allowed to post comments.