Oihana PHP Arango

median.php

Table of Contents

Functions

median()  : string
Return the median value of the values in an array.

Functions

median()

Return the median value of the values in an array.

median(mixed $anyArray) : string

This helper wraps the ArangoDB AQL function MEDIAN(anyArray) which returns the median (middle value) of all values in the given array. The median is the value separating the higher half from the lower half of the data set.

Example AQL usage:

MEDIAN([5, 2, 9, 2])          // returns 3.5 (average of 2 and 5)
MEDIAN([1, 2, 3, 4, 5])       // returns 3 (middle value)
MEDIAN([1, 2, 3, 4])          // returns 2.5 (average of 2 and 3)
MEDIAN(doc.scores)            // returns median of scores array
Parameters
$anyArray : mixed

Array expression containing numeric values.

Tags
example
use function oihana\arango\db\functions\numerics\median;

$expr = median('[5, 2, 9, 2]');
// Produces: 'MEDIAN([5, 2, 9, 2])'
see
https://docs.arangodb.com/stable/aql/functions/numeric/#median
average()

For calculating the mean.

percentile()

For calculating percentiles.

since
1.0.0
author

Marc Alcaraz

Return values
string

The formatted AQL expression.

On this page

Search results