Operator Reference

tuple_mediantuple_medianTupleMedianTupleMediantuple_median (Operator)

tuple_mediantuple_medianTupleMedianTupleMediantuple_median — Return the median of the elements of a tuple.

Signature

tuple_median( : : Tuple : Median)

Herror tuple_median(const Hlong Tuple, Hlong* Median)

Herror T_tuple_median(const Htuple Tuple, Htuple* Median)

void TupleMedian(const HTuple& Tuple, HTuple* Median)

HTuple HTuple::TupleMedian() const

static void HOperatorSet.TupleMedian(HTuple tuple, out HTuple median)

HTuple HTuple.TupleMedian()

def tuple_median(tuple: MaybeSequence[Union[float, int]]) -> Union[int, float]

Description

tuple_mediantuple_medianTupleMedianTupleMediantuple_median calculates the median of all elements of the input tuple TupleTupleTupletupletuple and returns it in the output parameter MedianMedianMedianmedianmedian. The input tuple may only consist of numbers (integer or floating point numbers). The median is defined as the element with rank n/2 (see tuple_select_ranktuple_select_rankTupleSelectRankTupleSelectRanktuple_select_rank).

Note that for an even number of input elements, this will return the upper median, not the arithmetic median. To calculate the arithmetic median, you can use tuple_select_ranktuple_select_rankTupleSelectRankTupleSelectRanktuple_select_rank to select the upper and lower median values and then calculate the arithmetic mean of both values.

Exception: Empty input tuple

If the input tuple is empty, an exception is raised.

HDevelop In-line Operation

HDevelop provides an in-line operation for tuple_mediantuple_medianTupleMedianTupleMediantuple_median, which can be used in an expression in the following syntax:

Median := median(Tuple)

Execution Information

  • Multithreading type: independent (runs in parallel even with exclusive operators).
  • Multithreading scope: global (may be called from any thread).
  • Processed without parallelization.

Parameters

TupleTupleTupletupletuple (input_control)  number(-array) HTupleMaybeSequence[Union[float, int]]HTupleHtuple (integer / real) (int / long / double) (Hlong / double) (Hlong / double)

Input tuple.

MedianMedianMedianmedianmedian (output_control)  number HTupleUnion[int, float]HTupleHtuple (integer / real) (int / long / double) (Hlong / double) (Hlong / double)

Median of the tuple elements.

Alternatives

tuple_select_ranktuple_select_rankTupleSelectRankTupleSelectRanktuple_select_rank

See also

tuple_meantuple_meanTupleMeanTupleMeantuple_mean, tuple_mintuple_minTupleMinTupleMintuple_min, tuple_maxtuple_maxTupleMaxTupleMaxtuple_max

Module

Foundation