tatami_stats
Matrix statistics for tatami
Loading...
Searching...
No Matches
Classes | Functions
tatami_stats::medians Namespace Reference

Functions for computing dimension-wise medians. More...

Classes

struct  Options
 Median calculation options. More...
 

Functions

template<typename Output_ = double, typename Value_ , typename Index_ >
Output_ direct (Value_ *ptr, Index_ num, bool skip_nan)
 
template<typename Output_ = double, typename Value_ , typename Index_ >
Output_ direct (Value_ *value, Index_ num_nonzero, Index_ num_all, bool skip_nan)
 
template<typename Value_ , typename Index_ , typename Output_ >
void apply (bool row, const tatami::Matrix< Value_, Index_ > *p, Output_ *output, const medians::Options &mopt)
 
template<typename Output_ = double, typename Value_ , typename Index_ >
std::vector< Output_ > by_column (const tatami::Matrix< Value_, Index_ > *p, const Options &mopt)
 
template<typename Output_ = double, typename Value_ , typename Index_ >
std::vector< Output_ > by_column (const tatami::Matrix< Value_, Index_ > *p)
 
template<typename Output_ = double, typename Value_ , typename Index_ >
std::vector< Output_ > by_row (const tatami::Matrix< Value_, Index_ > *p, const Options &mopt)
 
template<typename Output_ = double, typename Value_ , typename Index_ >
std::vector< Output_ > by_row (const tatami::Matrix< Value_, Index_ > *p)
 

Detailed Description

Functions for computing dimension-wise medians.

Function Documentation

◆ direct() [1/2]

template<typename Output_ = double, typename Value_ , typename Index_ >
Output_ tatami_stats::medians::direct ( Value_ *  ptr,
Index_  num,
bool  skip_nan 
)

Directly compute the median from a dense objective vector.

Parameters
[in]ptrPointer to an array of length num, containing the values of the objective vector. This may be modified on output.
numLength of the objective vector, i.e., length of the array at ptr.
skip_nanSee Options::skip_nan for details.
Template Parameters
Output_Type of the output value. This should be floating-point to store potential averages.
Value_Type of the input values.
Index_Type of the row/column indices.
Returns
The median of values in [ptr, ptr + n).

◆ direct() [2/2]

template<typename Output_ = double, typename Value_ , typename Index_ >
Output_ tatami_stats::medians::direct ( Value_ *  value,
Index_  num_nonzero,
Index_  num_all,
bool  skip_nan 
)

Directly compute the median from a sparse objective vector.

Parameters
[in]valuePointer to an array of length num_nonzero, containing values of the structural non-zeroes. This may be modified on output.
num_nonzeroNumber of structural non-zeros in the objective vector.
num_allLength of the obejctive vector, including the structural zeros, i.e., num_all - num_nonzero is the number of zeros.
skip_nanSee Options::skip_nan for details.
Template Parameters
Output_Type of the output value. This should be floating-point to store potential averages.
Value_Type of the input values.
Index_Type of the row/column indices.
Returns
The median of values in the sparse vector.

◆ apply()

template<typename Value_ , typename Index_ , typename Output_ >
void tatami_stats::medians::apply ( bool  row,
const tatami::Matrix< Value_, Index_ > *  p,
Output_ *  output,
const medians::Options mopt 
)

Compute medians for each element of a chosen dimension of a tatami::Matrix.

Template Parameters
Value_Type of the matrix value, should be numeric.
Index_Type of the row/column indices.
Output_Type of the output value. This should be floating-point to store potential averages.
Parameters
rowWhether to compute the median for each row. If false, the median is computed for each column instead.
pPointer to a tatami::Matrix.
[out]outputPointer to an array of length equal to the number of rows (if row = true) or columns (otherwise). On output, this will contain the row/column medians.
moptMedian calculation options.

◆ by_column() [1/2]

template<typename Output_ = double, typename Value_ , typename Index_ >
std::vector< Output_ > tatami_stats::medians::by_column ( const tatami::Matrix< Value_, Index_ > *  p,
const Options mopt 
)

Wrapper around apply() for column medians.

Template Parameters
Output_Type of the output. This should be floating-point to store potential averages.
Value_Type of the matrix value.
Index_Type of the row/column indices.
Parameters
pPointer to a tatami::Matrix.
moptMedian calculation options.
Returns
A vector of length equal to the number of columns, containing the column medians.

◆ by_column() [2/2]

template<typename Output_ = double, typename Value_ , typename Index_ >
std::vector< Output_ > tatami_stats::medians::by_column ( const tatami::Matrix< Value_, Index_ > *  p)

Overload with default options.

Template Parameters
Output_Type of the output. This should be floating-point to store potential averages.
Value_Type of the matrix value.
Index_Type of the row/column indices.
Parameters
pPointer to a tatami::Matrix.
Returns
A vector of length equal to the number of columns, containing the column medians.

◆ by_row() [1/2]

template<typename Output_ = double, typename Value_ , typename Index_ >
std::vector< Output_ > tatami_stats::medians::by_row ( const tatami::Matrix< Value_, Index_ > *  p,
const Options mopt 
)

Wrapper around apply() for row medians.

Template Parameters
Output_Type of the output. This should be floating-point to store potential averages.
Value_Type of the matrix value.
Index_Type of the row/column indices.
Parameters
pPointer to a tatami::Matrix.
moptMedian calculation options.
Returns
A vector of length equal to the number of rows, containing the row medians.

◆ by_row() [2/2]

template<typename Output_ = double, typename Value_ , typename Index_ >
std::vector< Output_ > tatami_stats::medians::by_row ( const tatami::Matrix< Value_, Index_ > *  p)

Overload with default options.

Template Parameters
Output_Type of the output. This should be floating-point to store potential averages.
Value_Type of the matrix value.
Index_Type of the row/column indices.
Parameters
pPointer to a tatami::Matrix.
Returns
A vector of length equal to the number of rows, containing the row medians.