User Tools

Site Tools


mode_mode_of_a_set_.htm
Navigation:  Templates > Guide to all Templates > Additional Libraries and Templates > Statistics Library >====== MODE (mode of a set) ====== Previous pageReturn to chapter overviewNext page

MODE(dataset,modeset)

blk2blue.jpg

MODE Identifies the value(s) that occurs most often in a numeric set and returns the number of times it occurs.
dataset The label of a QUEUE with its first component field defined as a REAL.
modeset The label of a QUEUE with its first component field defined as a REAL.

**MODE **determines which value or values within a numeric set occurs most often. The value or values are then stored in the passed QUEUE (modeset), and the function returns the number of occurrences (mode count).

The function operates on the numeric set defined by all the entries in the first component of the designated QUEUE (dataset). //Modeset //must be a QUEUE with the first component defined as a REAL variable. The contents of the //modeset //QUEUE are freed upon entry to the function.

For example, given the data set: [5,5,7,7,9] the returned mode count is 2 and the //modeset //QUEUE would contain two separate entries: 5 and 7.

NoteBox.jpg

The passed data set does not have to be sorted. The function copies the passed set. The passed data set is unchanged.

Return DataType:     REAL

Example:

StatSetX   QUEUE,PRE()

X           REAL

**           END**

ModeSet    QUEUE,PRE()

ModeValue   REAL

**           END**

ModeCount  REAL

**CODE **

** FREE(StatSetX)                   !free the QUEUE**

** CLEAR(STADAT:RECORD)             !clear the record buffer**

** STADAT:Id = STA:Id               !prime the record buffer**

** STADAT:ItemNumber = 1**

** SET(STADAT:KeyIdItemNumber,STADAT:KeyIdItemNumber !position file pointer**

** LOOP                             !load the QUEUE**

**   NEXT(StatisticsData)           !read next record**

**   IF ERRORCODE() OR STADAT:Id NOT = STA:Id**

**     BREAK**

**   ELSE**

**     StatSetX:X = STADAT:X        !load the QUEUE buffer**

**     ADD(StatSetX)                !add to the QUEUE**

**   END**

** END**

** ModeCount = MODE(StatSetX,ModeSet) !call MODE**

mode_mode_of_a_set_.htm.txt · Last modified: by 127.0.0.1