statistics.median
The median: the middle value, or the midpoint `(a + b) / 2` of the two middle values. The midpoint is correctly rounded. `quantile(values, 0.5)` computes `a + 0.5 * (b - a)`, which can differ from it in the last bit.
CLI- Package
- @procedures/statistics · README
- Path
["statistics","median"]- CLI
mark statistics median --values <number[]>- As data
{"$proc":["statistics","median"],"input":{}}
Use it
In TypeScript
import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/statistics/register"; // registers its procedures
const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["statistics","median"], { values: [] });
console.log(JSON.stringify(result));From the command line
$ mark statistics median --values <number[]>
As data, in a program
{ "$proc": ["statistics", "median"], "input": { "values": [] } }Input
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
values | number[] | yes |
Output
The schema does not list fields (number).
JSON Schemas
{
"input": {
"type": "object",
"properties": {
"values": {
"type": "array",
"items": {
"type": "number"
}
}
},
"required": [
"values"
],
"additionalProperties": false
},
"output": {
"type": "number"
}
}