# Measures of Mean (Median) (G Dataflow)

Version:
Last Modified: January 9, 2017

Finds the median value of a sequence by sorting the values in the sequence and averaging the middle element(s) of the sorted array.

## x

Input sequence.

If x is empty, median is NaN.

## error in

Error conditions that occur before this node runs. The node responds to this input according to standard error behavior.

Default: No error

## median

Calculated median value of the input sequence.

## error out

Error information. The node produces this output according to standard error behavior.

## Finding the Median Value of a Sequence

The node finds median using the following equation.

$\text{median}=\left\{\begin{array}{cc}{s}_{i}& \text{if}n\text{is odd}\\ 0.5\left({s}_{k-1}+{s}_{k}\right)& \text{if}n\text{is even}\end{array}$

where

• n is the number of elements in the input sequence x
• s is the sorted sequence of x
• $i=\frac{n-1}{2}$
• $k=\frac{n}{2}$

Where This Node Can Run:

Desktop OS: Windows

FPGA: Not supported