﻿ thinBasic Modules > STAT (Statistical module) > Stat_Min
 Navigation:  thinBasic Modules > STAT (Statistical module) > 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:

 • if Results is a single variable, its value will contain the position inside ArrayVariable where the min value is located
 • if Results is a 2 element array, first item will contain the position where min value is located and second item will contain the min 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

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

'---Or if you prefer to fill with random data from 1 to %ELEMENTS

'---Now some basic stats: Sum, Min, Max

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