Navigation: thinBasic Modules > STAT > Stat_Min |
|
Description
Returns the minimum element value inside an array.
Syntax
n = STAT_Min(ArrayVariable [, Results])
Returns
Number. The minimum 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:
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
© 2004-2008 thinBasic. All rights reserved. | Version 1.7.0.0 | Web Site: http://www.thinbasic.com |