Difference between revisions of "Documentation/How Tos/Calc: MODE function"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (layout)
Line 7: Line 7:
 
<tt>'''MODE(number1; number2; ... number30)'''</tt>
 
<tt>'''MODE(number1; number2; ... number30)'''</tt>
  
: <tt>'''number1'''</tt> to <tt>'''number30'''</tt> are up to 30 numbers or ranges containing numbers.
+
: <tt>'''number1'''</tt> to <tt>'''number30'''</tt> are up to 30 numbers or ranges/arrays containing numbers.
  
 
: <tt>'''MODE'''</tt> returns the number that occurs most often, or if more than one number occurs that many times, the smallest such number. If no number occurs more than once, <tt>'''MODE'''</tt> returns an error.
 
: <tt>'''MODE'''</tt> returns the number that occurs most often, or if more than one number occurs that many times, the smallest such number. If no number occurs more than once, <tt>'''MODE'''</tt> returns an error.
  
  
: Advanced topic: <tt>'''MODE'''</tt> evaluates as an [[Documentation/How_Tos/Using_Arrays|array formula]] - see the examples.
+
: <i>Advanced topic:</i> <tt>'''MODE'''</tt> evaluates its parameters as [[Documentation/How_Tos/Using_Arrays|array formulas]] - see the examples.
  
 
=== Example: ===
 
=== Example: ===
 +
<tt>'''MODE(A1:A4)'''</tt>
 +
: where cells <tt>'''A1:A4'''</tt> contain <tt>'''1'''</tt>, <tt>'''3'''</tt>, <tt>'''2'''</tt>, <tt>'''3'''</tt> returns <tt>'''3'''</tt>, the number occurring most often.
  
<tt>'''MODE(3; 7; 3; 9; 9; 3; 5; 1; 8; 5)'''</tt>
+
<tt>'''MODE(3; 7; 3; 9; 9; 3; 5; 1; 9; 5)'''</tt>
: returns <tt>'''3'''</tt>, the number occuring most often.
+
: returns <tt>'''3'''</tt>. The number <tt>'''9'''</tt> occurs the same number of times, but <tt>'''3'''</tt> is smaller.
  
  
Evaluation as an [[Documentation/How_Tos/Using_Arrays|array formula]]:
+
<i>Advanced topic:</i> Evaluation as an [[Documentation/How_Tos/Using_Arrays|array formula]]:
  
 
<tt>'''MODE(ABS({1; 1; 1; 2; 2; -2; -2}))'''</tt>
 
<tt>'''MODE(ABS({1; 1; 1; 2; 2; -2; -2}))'''</tt>

Revision as of 17:07, 9 May 2008


MODE

Returns the most common value in a data set.

Syntax:

MODE(number1; number2; ... number30)

number1 to number30 are up to 30 numbers or ranges/arrays containing numbers.
MODE returns the number that occurs most often, or if more than one number occurs that many times, the smallest such number. If no number occurs more than once, MODE returns an error.


Advanced topic: MODE evaluates its parameters as array formulas - see the examples.

Example:

MODE(A1:A4)

where cells A1:A4 contain 1, 3, 2, 3 returns 3, the number occurring most often.

MODE(3; 7; 3; 9; 9; 3; 5; 1; 9; 5)

returns 3. The number 9 occurs the same number of times, but 3 is smaller.


Advanced topic: Evaluation as an array formula:

MODE(ABS({1; 1; 1; 2; 2; -2; -2}))

returns 2. The ABS function normally takes a single number, but here it is given an array. MODE forces the formula to be an array formula, so that the absolute value of each number in the array is found, and given to MODE as the array {1; 1; 1; 2; 2; 2; 2}. The most common value is now 2.

See also:

AVERAGE, AVERAGEA, MEDIAN

ABS

Statistical functions

Using Arrays

Personal tools