Because sorting functions need to access the tensor data repeatedly, they evaluate their input and may allocate temporaries.
More...
|
template<class E> |
auto | xt::sort (const xexpression< E > &e, std::ptrdiff_t axis=-1) |
| Sort xexpression (optionally along axis) The sort is performed using the std::sort functions.
|
|
template<class E> |
auto | xt::argsort (const xexpression< E > &e, std::ptrdiff_t axis=-1, sorting_method method=sorting_method::quick) |
| Argsort xexpression (optionally along axis) Performs an indirect sort along the given axis.
|
|
template<class E, class C, class R = detail::flatten_sort_result_type_t<E>, class = std::enable_if_t<!xtl::is_integral<C>::value, int>> |
R | xt::partition (const xexpression< E > &e, C kth_container, placeholders::xtuph) |
| Partially sort xexpression.
|
|
template<class E, class C, class R = typename detail::linear_argsort_result_type<typename detail::sort_eval_type<E>::type>::type, class = std::enable_if_t<!xtl::is_integral<C>::value, int>> |
R | xt::argpartition (const xexpression< E > &e, C kth_container, placeholders::xtuph) |
| Partially sort arguments.
|
|
template<class T = double, class E, class P> |
auto | xt::quantile (E &&e, const P &probas, std::ptrdiff_t axis, T alpha, T beta) |
| Compute quantiles over the given axis.
|
|
template<class T = double, class E, class P> |
auto | xt::quantile (E &&e, const P &probas, T alpha, T beta) |
| Compute quantiles of the whole expression.
|
|
template<class T = double, class E, class P> |
auto | xt::quantile (E &&e, const P &probas, std::ptrdiff_t axis, quantile_method method=quantile_method::linear) |
| Compute quantiles over the given axis.
|
|
template<class T = double, class E, class P> |
auto | xt::quantile (E &&e, const P &probas, quantile_method method=quantile_method::linear) |
| Compute quantiles of the whole expression.
|
|
template<class E> |
auto | xt::median (E &&e, std::ptrdiff_t axis) |
| Find the median along the specified axis.
|
|
template<layout_type L = ::xt::layout_type::row_major, class E> |
auto | xt::argmax (const xexpression< E > &e, std::ptrdiff_t axis) |
| Find position of maximal value in xexpression By default, the returned index is into the flattened array.
|
|
template<class E> |
auto | xt::unique (const xexpression< E > &e) |
| Find unique elements of a xexpression.
|
|
template<class E1, class E2> |
auto | xt::setdiff1d (const xexpression< E1 > &ar1, const xexpression< E2 > &ar2) |
| Find the set difference of two xexpressions.
|
|
Because sorting functions need to access the tensor data repeatedly, they evaluate their input and may allocate temporaries.
template<class E, class C, class R = typename detail::linear_argsort_result_type<typename detail::sort_eval_type<E>::type>::type, class = std::enable_if_t<!xtl::is_integral<C>::value, int>>
Partially sort arguments.
Argpartition shuffles the indices to a xexpression in a way so that the index for the kth element in the returned xexpression is in the place it would appear in a sorted array and all elements smaller than this entry are placed (unsorted) before.
The optional third parameter can either be an axis or xnone()
in which case the xexpression will be flattened.
This function uses std::nth_element
internally.
and 3
R argpartition(const xexpression< E > &e, C kth_container, placeholders::xtuph)
Partially sort arguments.
xarray_container< uvector< T, A >, L, xt::svector< typename uvector< T, A >::size_type, 4, SA, true > > xarray
Alias template on xarray_container with default parameters for data container type and shape / stride...
- Parameters
-
e | input xexpression |
kth_container | a container of indices that should contain the correctly sorted value |
axis | either integer (default = -1) to sort along last axis or xnone() to flatten before sorting |
- Returns
- xcontainer with indices of partial sort of input
Definition at line 664 of file xsort.hpp.
template<class E>
auto xt::median |
( |
E && | e, |
|
|
std::ptrdiff_t | axis ) |
|
inline |
Find the median along the specified axis.
Given a vector V of length N, the median of V is the middle value of a sorted copy of V, V_sorted - i e., V_sorted[(N-1)/2], when N is odd, and the average of the two middle values of V_sorted when N is even.
- Parameters
-
axis | axis along which the medians are computed. If not set, computes the median along a flattened version of the input. |
e | input xexpression |
- Returns
- median value
Definition at line 1126 of file xsort.hpp.
template<class E, class C, class R = detail::flatten_sort_result_type_t<E>, class = std::enable_if_t<!xtl::is_integral<C>::value, int>>
Partially sort xexpression.
Partition shuffles the xexpression in a way so that the kth element in the returned xexpression is in the place it would appear in a sorted array and all elements smaller than this entry are placed (unsorted) before.
The optional third parameter can either be an axis or xnone()
in which case the xexpression will be flattened.
This function uses std::nth_element
internally.
and 3
R partition(const xexpression< E > &e, C kth_container, placeholders::xtuph)
Partially sort xexpression.
- Parameters
-
e | input xexpression |
kth_container | a container of indices that should contain the correctly sorted value |
axis | either integer (default = -1) to sort along last axis or xnone() to flatten before sorting |
- Returns
- partially sorted xcontainer
Definition at line 569 of file xsort.hpp.
template<class T = double, class E, class P>
auto xt::quantile |
( |
E && | e, |
|
|
const P & | probas, |
|
|
std::ptrdiff_t | axis, |
|
|
T | alpha, |
|
|
T | beta ) |
|
inline |
Compute quantiles over the given axis.
In a sorted array represneting a distribution of numbers, the quantile of a probability p
is the the cut value q
such that a fraction p
of the distribution is lesser or equal to q
. When the cutpoint falls between two elemnts of the sample distribution, a interpolation is computed using the alpha
and beta
coefficients, as descripted in (Hyndman and Fan, 1996).
The algorithm partially sorts entries in a copy along the axis
axis.
- Parameters
-
e | Expression containing the distribution over which the quantiles are computed. |
probas | An list of probability associated with each desired quantiles. All elements must be in the range [0, 1] . |
axis | The dimension in which to compute the quantiles, i.e the axis representing the distribution. |
alpha | Interpolation parameter. Must be in the range [0, 1]] . |
beta | Interpolation parameter. Must be in the range [0, 1]] . |
- Template Parameters
-
T | The type in which the quantile are computed. |
- Returns
- An expression with as many dimensions as the input
e
. The first axis correspond to the quantiles. The other axes are the axes that remain after the reduction of e
.
- See also
- (Hyndman and Fan, 1996) R. J. Hyndman and Y. Fan, "Sample quantiles in statistical packages", The American Statistician, 50(4), pp. 361-365, 1996
-
https://en.wikipedia.org/wiki/Quantile
Definition at line 906 of file xsort.hpp.