xtensor
Loading...
Searching...
No Matches
nan functions

Functions

template<class E >
auto xt::nan_to_num (E &&e)
 Convert nan or +/- inf to numbers.
 
template<class T = void, class E , class X , class EVS = std::tuple<evaluation_strategy::lazy_type>, xtl::check_concept< xtl::negation< is_reducer_options< X > >, xtl::negation< xtl::is_integral< std::decay_t< X > > > > = 0>
auto xt::nanmin (E &&e, X &&axes, EVS es=EVS())
 Minimum element over given axes, ignoring NaNs.
 
template<class T = void, class E , class X , class EVS = std::tuple<evaluation_strategy::lazy_type>, xtl::check_concept< xtl::negation< is_reducer_options< X > >, xtl::negation< xtl::is_integral< std::decay_t< X > > > > = 0>
auto xt::nanmax (E &&e, X &&axes, EVS es=EVS())
 Maximum element along given axes, ignoring NaNs.
 
template<class T = void, class E , class X , class EVS = std::tuple<evaluation_strategy::lazy_type>, xtl::check_concept< xtl::negation< is_reducer_options< X > >, xtl::negation< xtl::is_integral< std::decay_t< X > > > > = 0>
auto xt::nansum (E &&e, X &&axes, EVS es=EVS())
 Sum of elements over given axes, replacing NaN with 0.
 
template<class T = void, class E , class X , class EVS = std::tuple<evaluation_strategy::lazy_type>, xtl::check_concept< xtl::negation< is_reducer_options< X > >, xtl::negation< xtl::is_integral< std::decay_t< X > > > > = 0>
auto xt::nanprod (E &&e, X &&axes, EVS es=EVS())
 Product of elements over given axes, replacing NaN with 1.
 
template<class T = void, class E >
auto xt::nancumsum (E &&e, std::ptrdiff_t axis)
 Cumulative sum, replacing nan with 0.
 
template<class T = void, class E >
auto xt::nancumprod (E &&e, std::ptrdiff_t axis)
 Cumulative product, replacing nan with 1.
 
template<class T = void, class E , class X , class EVS = std::tuple<evaluation_strategy::lazy_type>, xtl::check_concept< xtl::negation< is_reducer_options< X > > > = 0>
auto xt::nanmean (E &&e, X &&axes, EVS es=EVS())
 Mean of elements over given axes, excluding NaNs.
 
template<class T = void, class E , class X , class EVS = std::tuple<evaluation_strategy::lazy_type>, xtl::check_concept< xtl::negation< is_reducer_options< X > > > = 0>
auto xt::nanvar (E &&e, X &&axes, EVS es=EVS())
 Compute the variance along the specified axes, excluding NaNs.
 
template<class T = void, class E , class X , class EVS = std::tuple<evaluation_strategy::lazy_type>, xtl::check_concept< xtl::negation< is_reducer_options< X > > > = 0>
auto xt::nanstd (E &&e, X &&axes, EVS es=EVS())
 Compute the standard deviation along the specified axis, excluding nans.
 

Detailed Description

Function Documentation

◆ nan_to_num()

template<class E >
auto xt::nan_to_num ( E && e)
inline

Convert nan or +/- inf to numbers.

This functions converts NaN to 0, and +inf to the highest, -inf to the lowest floating point value of the same type.

Parameters
einput xexpression
Returns
an xexpression

Definition at line 2447 of file xmath.hpp.

◆ nancumprod()

template<class T = void, class E >
auto xt::nancumprod ( E && e,
std::ptrdiff_t axis )
inline

Cumulative product, replacing nan with 1.

Returns an xaccumulator for the product of elements over given axis, replacing nan with 1.

Parameters
ean xexpression
axisthe axis along which the elements are accumulated (optional)
Template Parameters
Tthe value type used for internal computation. The default is E::value_type. T is also used for determining the value type of the result, which is the type of T() * E::value_type(). You can pass big_promote_value_type_t<E> to avoid overflow in computation.
Returns
an xaccumulator

Definition at line 2665 of file xmath.hpp.

◆ nancumsum()

template<class T = void, class E >
auto xt::nancumsum ( E && e,
std::ptrdiff_t axis )
inline

Cumulative sum, replacing nan with 0.

Returns an xaccumulator for the sum of elements over given axis, replacing nan with 0.

Parameters
ean xexpression
axisthe axis along which the elements are accumulated (optional)
Template Parameters
Tthe value type used for internal computation. The default is E::value_type. T is also used for determining the value type of the result, which is the type of T() + E::value_type(). You can pass big_promote_value_type_t<E> to avoid overflow in computation.
Returns
an xaccumulator

Definition at line 2630 of file xmath.hpp.

◆ nanmax()

template<class T = void, class E , class X , class EVS = std::tuple<evaluation_strategy::lazy_type>, xtl::check_concept< xtl::negation< is_reducer_options< X > >, xtl::negation< xtl::is_integral< std::decay_t< X > > > > = 0>
auto xt::nanmax ( E && e,
X && axes,
EVS es = EVS() )
inline

Maximum element along given axes, ignoring NaNs.

Returns an xreducer for the sum of elements over given axes, ignoring NaN.

Warning
Casting the result to an integer type can cause undefined behavior.
Parameters
ean xexpression
axesthe axes along which the sum is performed (optional)
esevaluation strategy of the reducer (optional)
Template Parameters
Tthe result type. The default is E::value_type.
Returns
an xreducer

Definition at line 2480 of file xmath.hpp.

◆ nanmean()

template<class T = void, class E , class X , class EVS = std::tuple<evaluation_strategy::lazy_type>, xtl::check_concept< xtl::negation< is_reducer_options< X > > > = 0>
auto xt::nanmean ( E && e,
X && axes,
EVS es = EVS() )
inline

Mean of elements over given axes, excluding NaNs.

Returns an xreducer for the mean of elements over given axes, excluding NaNs. This is not the same as counting NaNs as zero, since excluding NaNs changes the number of elements considered in the statistic.

Parameters
ean xexpression
axesthe axes along which the mean is computed (optional)
esthe evaluation strategy (optional)
Template Parameters
Tthe result type. The default is E::value_type. You can pass big_promote_value_type_t<E> to avoid overflow in computation.
Returns
an xexpression

Definition at line 2749 of file xmath.hpp.

◆ nanmin()

template<class T = void, class E , class X , class EVS = std::tuple<evaluation_strategy::lazy_type>, xtl::check_concept< xtl::negation< is_reducer_options< X > >, xtl::negation< xtl::is_integral< std::decay_t< X > > > > = 0>
auto xt::nanmin ( E && e,
X && axes,
EVS es = EVS() )
inline

Minimum element over given axes, ignoring NaNs.

Returns an xreducer for the minimum of elements over given axes, ignoring NaNs.

Warning
Casting the result to an integer type can cause undefined behavior.
Parameters
ean xexpression
axesthe axes along which the minimum is found (optional)
esevaluation strategy of the reducer (optional)
Template Parameters
Tthe result type. The default is E::value_type.
Returns
an xreducer

Definition at line 2465 of file xmath.hpp.

◆ nanprod()

template<class T = void, class E , class X , class EVS = std::tuple<evaluation_strategy::lazy_type>, xtl::check_concept< xtl::negation< is_reducer_options< X > >, xtl::negation< xtl::is_integral< std::decay_t< X > > > > = 0>
auto xt::nanprod ( E && e,
X && axes,
EVS es = EVS() )
inline

Product of elements over given axes, replacing NaN with 1.

Returns an xreducer for the sum of elements over given axes, replacing nan with 1.

Parameters
ean xexpression
axesthe axes along which the sum is performed (optional)
esevaluation strategy of the reducer (optional)
Template Parameters
Tthe value type used for internal computation. The default is E::value_type. T is also used for determining the value type of the result, which is the type of T() * E::value_type(). You can pass big_promote_value_type_t<E> to avoid overflow in computation.
Returns
an xreducer

Definition at line 2514 of file xmath.hpp.

◆ nanstd()

template<class T = void, class E , class X , class EVS = std::tuple<evaluation_strategy::lazy_type>, xtl::check_concept< xtl::negation< is_reducer_options< X > > > = 0>
auto xt::nanstd ( E && e,
X && axes,
EVS es = EVS() )
inline

Compute the standard deviation along the specified axis, excluding nans.

Returns the standard deviation, a measure of the spread of a distribution, of the array elements. The standard deviation is computed for the flattened array by default, otherwise over the specified axis. Excluding NaNs changes the number of elements considered in the statistic.

Note: this function is not yet specialized for complex numbers.

Parameters
ean xexpression
axesthe axes along which the standard deviation is computed (optional)
esevaluation strategy to use (lazy (default), or immediate)
Template Parameters
Tthe result type. The default is E::value_type. You can pass big_promote_value_type_t<E> to avoid overflow in computation.
Returns
an xexpression
See also
nanvar, nanmean

Definition at line 2874 of file xmath.hpp.

◆ nansum()

template<class T = void, class E , class X , class EVS = std::tuple<evaluation_strategy::lazy_type>, xtl::check_concept< xtl::negation< is_reducer_options< X > >, xtl::negation< xtl::is_integral< std::decay_t< X > > > > = 0>
auto xt::nansum ( E && e,
X && axes,
EVS es = EVS() )
inline

Sum of elements over given axes, replacing NaN with 0.

Returns an xreducer for the sum of elements over given axes, ignoring NaN.

Parameters
ean xexpression
axesthe axes along which the sum is performed (optional)
esevaluation strategy of the reducer (optional)
Template Parameters
Tthe value type used for internal computation. The default is E::value_type. T is also used for determining the value type of the result, which is the type of T() + E::value_type(). You can pass big_promote_value_type_t<E> to avoid overflow in computation.
Returns
an xreducer

Definition at line 2497 of file xmath.hpp.

◆ nanvar()

template<class T = void, class E , class X , class EVS = std::tuple<evaluation_strategy::lazy_type>, xtl::check_concept< xtl::negation< is_reducer_options< X > > > = 0>
auto xt::nanvar ( E && e,
X && axes,
EVS es = EVS() )
inline

Compute the variance along the specified axes, excluding NaNs.

Returns the variance of the array elements, a measure of the spread of a distribution. The variance is computed for the flattened array by default, otherwise over the specified axes. Excluding NaNs changes the number of elements considered in the statistic.

Note: this function is not yet specialized for complex numbers.

Parameters
ean xexpression
axesthe axes along which the variance is computed (optional)
esevaluation strategy to use (lazy (default), or immediate)
Template Parameters
Tthe result type. The default is E::value_type. You can pass big_promote_value_type_t<E> to avoid overflow in computation.
Returns
an xexpression
See also
nanstd, nanmean

Definition at line 2826 of file xmath.hpp.