This documentation was styled with a demo skin from the Premium Pack 4 add-on for Help & Manual. The contents of the skin are encrypted and not configurable. You can only publish HM projects with this skin. You cannot edit it or change it.
This version is copyright and may only be used for local testing purposes. It may not be distributed.
Please purchase the full version of the Premium Pack to get the configurable skins and remove this notice. The package will also include the Toolbox configuration utility for Premium Pack skins.
Description
Returns the maximum element value inside an array.
Syntax
n = STAT_Max(ArrayVariable [, Results])
Returns
Number. The maximum value
Parameters
Name |
Type |
Optional |
Meaning |
ArrayVariable |
Numeric Array |
No |
The array containing data |
Results |
Numeric Array or variable |
Yes |
An optional numeric array or variable. If present it will be filled with return values depending on its size. For example: •if Results is a single variable, its value will contain the position inside ArrayVariable where the max value is located •if Results is a 2 element array, first item will contain the position where max value is located and second item will contain the max value found
This method to return data will be implemented if there will be requests. |
Remarks
This function will expect the name of a predefined array with all the necessary data already loaded.
Restrictions
See also
Examples
'---Instruct thinBasic to use STAT module
USES "STAT"
%ELEMENTS = 1000000
Dim aData(%ELEMENTS) As Ext
Dim sMsg As String
Dim lSum, lMin, lMax As Ext
Dim lMaxPos, lMinPos As Long
'---Fill the array with first %ELEMENTS natural numbers
Stat_FillArray(aData, %Stat_Fill_Natural)
'---Or if you prefer to fill with random data from 1 to %ELEMENTS
'Stat_Random(aData, 1, %ELEMENTS)
'---Now some basic stats: Sum, Min, Max
lSum = Stat_Sum(aData)
lMin = Stat_Min(aData, lMinPos)
lMax = Stat_Max(aData, lMaxPos)
sMsg = "Some very simple statistical functions" & $crlf
sMsg += "Sum: " & $Tab & lSum & $crlf
sMsg += "Min: " & $Tab & lMin & " ---> Min value is located at position " & lMinPos & " inside the array." & $crlf
sMsg += "Max: " & $Tab & lMax & " ---> Max value is located at position " & lMaxPos & " inside the array." & $crlf
msgbox 0, sMsg, 0, "Total Elements considered: " & %ELEMENTS