Functions Min and Max


Functions Min and Max

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

These return the smallest (Min) or largest (Max) values along an indicated index or indexes.

To find the larger of separate values, use:

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

The index parameter is optional, but it is highly recommended that you always specify the index except in the list-usage just mentioned, or in the case where you can guarantee that X will always be one-dimensional (such as when X is itself an index). In most cases, even if your array is 1-D today, it is better to specify the index explicitly so that the expression can correctly array abstract if new dimensions are introduced into your model in the future.

Optional Parameters

Multiple Indexes

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

You can list more than one index, e.g., Max(X,I,J), which is equivalent to Max(Max(X,I),J). The multi-index variation allows you to find the maximum or minimum within an N-Dimensional slice of X.

Non-Numerics

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

These optional boolean parameters require a named-parameter syntax. Sometimes you want to take the maximum of only the numeric values that appear, ignoring textual values and other non-numeric values. (note: Null values are always ignored, even when this parameter is not specified) To do this, supply True for the «IgnoreNonNumerics» parameter, e.g.:

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. Since these are would-be numeric values, but just indeterminate (i.e., we have no way of knowing the real value), the result of a Min or Max on NaN is also indeterminate. 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.

As of 4.3.2, these functions do not support named parameter syntax. They also don't have any of the optional parameters supported by Min and Max (multiple indexes, case sensitivity). However, the «cond» parameter makes it easy to accomplish the same thing as the IgnoreNonNumerics or IgnoreNaNs parameters of Min and Max.

Related Functions

Comments


You are not allowed to post comments.