median: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Macros:Functions:median moved to median: Moved out of Macros namespace)
No edit summary
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
==Function median==
{{MacroFunction
 
|name=median
|description=
Returns the [[wp:Median|Median]] of the numbers passed in. The median value is the value where half the numbers in the list are higher or equal to it and the other half are lower or equal to it. The median is calculated by sorting the list of numbers and picking the middle number if the list has an odd amount or averaging the two in the middle if there is an even amount.  
Returns the [[wp:Median|Median]] of the numbers passed in. The median value is the value where half the numbers in the list are higher or equal to it and the other half are lower or equal to it. The median is calculated by sorting the list of numbers and picking the middle number if the list has an odd amount or averaging the two in the middle if there is an even amount.  
   


===Usage===
|usage=
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[h: av = median(num, num, ...)]
[h: av = median(num, num, ...)]
</source>
</syntaxhighlight>
 
 


===Examples===
|examples=
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
     [r: median(3,6,2,2)]   
     [r: median(3,6,2,2)]   
     [r: median(12, 23, 3, 102, 1)]
     [r: median(12, 23, 3, 102, 1)]
</source>
</syntaxhighlight>
Returns  
Returns  
     2.5
     2.5
     12
     12
}}
[[Category:Mathematical Function]]

Latest revision as of 23:59, 14 March 2023

median() Function

Returns the Median of the numbers passed in. The median value is the value where half the numbers in the list are higher or equal to it and the other half are lower or equal to it. The median is calculated by sorting the list of numbers and picking the middle number if the list has an odd amount or averaging the two in the middle if there is an even amount.

Usage

[h: av = median(num, num, ...)]

Examples

    [r: median(3,6,2,2)]   
    [r: median(12, 23, 3, 102, 1)]

Returns

   2.5
12