mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-25 15:07:57 +00:00
52 lines
1000 B
Markdown
52 lines
1000 B
Markdown
# Function median
|
|
|
|
Compute the median of a matrix or a list with values. The values are
|
|
sorted and the middle value is returned. In case of an even number of
|
|
values, the average of the two middle values is returned.
|
|
Supported types of values are: Number, BigNumber, Unit
|
|
|
|
In case of a (multi dimensional) array or matrix, the median of all
|
|
elements will be calculated.
|
|
|
|
|
|
## Syntax
|
|
|
|
```js
|
|
mean.median(a, b, c, ...)
|
|
mean.median(A)
|
|
```
|
|
|
|
### Parameters
|
|
|
|
Parameter | Type | Description
|
|
--------- | ---- | -----------
|
|
`args` | ... * | A single matrix or or multiple scalar values
|
|
|
|
### Returns
|
|
|
|
Type | Description
|
|
---- | -----------
|
|
* | The median
|
|
|
|
|
|
## Examples
|
|
|
|
```js
|
|
math.median(5, 2, 7); // returns 5
|
|
math.median([3, -1, 5, 7]); // returns 4
|
|
```
|
|
|
|
|
|
## See also
|
|
|
|
[mean](mean.md),
|
|
[min](min.md),
|
|
[max](max.md),
|
|
[sum](sum.md),
|
|
[prod](prod.md),
|
|
[std](std.md),
|
|
[var](var.md)
|
|
|
|
|
|
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
|