Function vector_median_sorted (o2scl)

O2scl : Function List

template<class vec_t>
double o2scl::vector_median_sorted(size_t n, const vec_t &data)

Return the median of sorted (ascending or descending) data.

This function returns the median of sorted data (either ascending or descending), assuming the data has already been sorted. When the data set has an odd number of elements, the median is the value of the element at index \( (n-1)/2 \), otherwise, the median is taken to be the average of the elements at indices \( (n-1)/2 \) and \( n/2 \) .

This function produces the same results as gsl_stats_median_from_sorted_data().

No checks are made to ensure the data is sorted. If n is zero, this function will return zero without calling the error handler.

template<class vec_t>
double o2scl::vector_median_sorted(const vec_t &data)

Return the median of sorted (ascending or descending) data.

This function returns the median of sorted data (either ascending or descending), assuming the data has already been sorted. When the data set has an odd number of elements, the median is the value of the element at index \( (n-1)/2 \), otherwise, the median is taken to be the average of the elements at indices \( (n-1)/2 \) and \( n/2 \) .

This function produces the same results as gsl_stats_median_from_sorted_data().

No checks are made to ensure the data is sorted. If n is zero, this function will return zero without calling the error handler.