Skip to main content
Version: 8.1

system.math.mode

This function is used in Python Scripting.

Description​

Given a sequence of values, returns the 'mode', or most frequent values.

Returns an empty list if the sequence was empty or None.

Client Permission Restrictions​

This scripting function has no Client Permission restrictions.

Syntax​

system.math.mode(values)

Parameters​

TypeParameterDescription
List[Float]valuesA sequence of numerical values. Accepts both integers and floats. The sequence may not contain None type values.

Returns​

List[Float] - A Java Array (functionally similar to a Python List) of floats representing the most frequent value(s) in the values parameter. If the values parameter was empty, then an empty list will be returned instead.

Scope​

Gateway, Vision Client, Perspective Session

Code Examples​

Example #1 - Getting the Mode from a List of Values
# Create a list of values.
values = [3.5, 5.6, 7.8, 7.4, 7.8]

# Return the most common values.
modes = system.math.mode(values)

# Print the first item in the result.
print modes[0]

# Iterate over the results.
for number in modes:
print number