tatami_stats
Matrix statistics for tatami
Loading...
Searching...
No Matches
tatami_stats::skip_nan Namespace Reference

Compute statistics from a tatami::Matrix while skipping NaNs. More...

Classes

struct  GroupRssBuffers
 Result buffers for skip_nan::group_rss(). More...
 
struct  GroupRssOptions
 Options for skip_nan::group_rss(). More...
 
struct  GroupRssResult
 Results of skip_nan::group_rss(). More...
 
struct  RssBuffers
 Result buffers for skip_nan::rss(). More...
 
struct  RssOptions
 Options for skip_nan::rss(). More...
 
struct  RssResult
 Results of skip_nan::rss(). More...
 

Functions

template<typename Value_ , typename Index_ , typename Group_ , typename Output_ , typename Count_ >
void group_rss (bool row, const tatami::Matrix< Value_, Index_ > &mat, const Group_ *const group, const std::size_t num_groups, GroupRssBuffers< Output_, Count_ > &output, const GroupRssOptions &opt)
 
template<typename Output_ , typename Count_ , typename Value_ , typename Index_ , typename Group_ >
GroupRssResult< Output_, Count_ > group_rss (bool row, const tatami::Matrix< Value_, Index_ > &mat, const Group_ *const group, const std::size_t num_groups, const GroupRssOptions &opt)
 
template<typename Value_ , typename Index_ , typename Output_ , typename Count_ >
void rss (bool row, const tatami::Matrix< Value_, Index_ > &mat, RssBuffers< Output_, Count_ > &output, const RssOptions &opt)
 
template<typename Output_ = double, typename Count_ , typename Value_ , typename Index_ >
RssResult< Output_, Count_ > rss (bool row, const tatami::Matrix< Value_, Index_ > &mat, const RssOptions &opt)
 

Detailed Description

Compute statistics from a tatami::Matrix while skipping NaNs.

Function Documentation

◆ group_rss() [1/2]

template<typename Value_ , typename Index_ , typename Group_ , typename Output_ , typename Count_ >
void tatami_stats::skip_nan::group_rss ( bool row,
const tatami::Matrix< Value_, Index_ > & mat,
const Group_ *const group,
const std::size_t num_groups,
GroupRssBuffers< Output_, Count_ > & output,
const GroupRssOptions & opt )

Compute per-group variances for each element of a chosen dimension of a tatami::Matrix.

Template Parameters
Value_Numeric type of the matrix value.
Index_Integer type of the row/column indices.
Group_Integer type of the group assignments for each row/column.
Output_Floating-point type of the output value. This should be capable of storing NaNs.
Count_Numeric type of the non-NaN counts. This is typically an integer type.
Parameters
rowWhether to compute variances for the rows.
matInstance of a tatami::Matrix.
[in]groupPointer to an array of length equal to the number of columns (if row = true) or rows (otherwise). Each value should be an integer that specifies the group assignment. Values should lie in \([0, N)\) where \(N\) is the number of unique groups.
num_groupsNumber of groups, i.e., \(N\).
[out]outputBuffers in which to store the results. On output, each array stores the means and variances of the corresponding group.
optFurther options.

◆ group_rss() [2/2]

template<typename Output_ , typename Count_ , typename Value_ , typename Index_ , typename Group_ >
GroupRssResult< Output_, Count_ > tatami_stats::skip_nan::group_rss ( bool row,
const tatami::Matrix< Value_, Index_ > & mat,
const Group_ *const group,
const std::size_t num_groups,
const GroupRssOptions & opt )

Compute per-group variances for each element of a chosen dimension of a tatami::Matrix.

Template Parameters
Output_Floating-point type of the output value. This should be capable of storing NaNs.
Count_Numeric type of the non-NaN counts. This is typically an integer type.
Value_Numeric type of the matrix value.
Index_Integer type of the row/column indices.
Group_Integer type of the group assignments for each row/column.
Parameters
rowWhether to compute variances for the rows.
matInstance of a tatami::Matrix.
[in]groupPointer to an array of length equal to the number of columns (if row = true) or rows (otherwise). Each value should be an integer that specifies the group assignment. Values should lie in \([0, N)\) where \(N\) is the number of unique groups.
num_groupsNumber of groups, i.e., \(N\).
optFurther options.
Returns
RSS and mean of each group for each row/column.

◆ rss() [1/2]

template<typename Value_ , typename Index_ , typename Output_ , typename Count_ >
void tatami_stats::skip_nan::rss ( bool row,
const tatami::Matrix< Value_, Index_ > & mat,
RssBuffers< Output_, Count_ > & output,
const RssOptions & opt )

Compute residual sums of squares (RSS) for each element of a chosen dimension of a tatami::Matrix, after skipping any NaNs. This may use either Welford's method or the standard two-pass method, depending on the dimension in row and the preferred access dimension of p.

Template Parameters
Value_Numeric type of the input data.
Index_Integer type of the row/column indices.
Output_Floating-point type of the output data. This should be capable of storing NaNs.
Count_Numeric type of the non-NaN counts. This is typically an integer type.
Parameters
rowWhether to compute the RSS for each row. If false, the RSS is computed for each column instead.
matInstance of a tatami::Matrix.
[out]outputBuffers to output arrays. On output, this will contain the row/column RSSs.
optFurther options.

◆ rss() [2/2]

template<typename Output_ = double, typename Count_ , typename Value_ , typename Index_ >
RssResult< Output_, Count_ > tatami_stats::skip_nan::rss ( bool row,
const tatami::Matrix< Value_, Index_ > & mat,
const RssOptions & opt )

Overload of skip_nan::rss() that allocates memory for the output arrays.

Template Parameters
Output_Floating-point type of the output data. This should be capable of storing NaNs.
Count_Numeric type of the non-NaN counts. This is typically an integer type.
Value_Numeric type of the input data.
Index_Integer type of the row/column indices.
Parameters
rowWhether to compute the RSS for each row. If false, the RSS is computed for each column instead.
matInstance of a tatami::Matrix.
optFurther options.
Returns
The mean and RSS of each row/column.