tatami_stats
Matrix statistics for tatami
|
Functions for computing dimension-wise variances. More...
Classes | |
struct | Options |
Variance calculation options. More... | |
class | RunningDense |
Running variances from dense data. More... | |
class | RunningSparse |
Running variances from sparse data. More... | |
Functions | |
template<typename Output_ = double, typename Value_ , typename Index_ > | |
std::pair< Output_, Output_ > | direct (const Value_ *value, Index_ num_nonzero, Index_ num_all, bool skip_nan) |
template<typename Output_ = double, typename Value_ , typename Index_ > | |
std::pair< Output_, Output_ > | direct (const Value_ *ptr, Index_ num, bool skip_nan) |
template<typename Value_ , typename Index_ , typename Output_ > | |
void | apply (bool row, const tatami::Matrix< Value_, Index_ > *p, Output_ *output, const Options &vopt) |
template<typename Output_ = double, typename Value_ , typename Index_ > | |
std::vector< Output_ > | by_column (const tatami::Matrix< Value_, Index_ > *p, const Options &vopt) |
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 &vopt) |
template<typename Output_ = double, typename Value_ , typename Index_ > | |
std::vector< Output_ > | by_row (const tatami::Matrix< Value_, Index_ > *p) |
Functions for computing dimension-wise variances.
std::pair< Output_, Output_ > tatami_stats::variances::direct | ( | const Value_ * | value, |
Index_ | num_nonzero, | ||
Index_ | num_all, | ||
bool | skip_nan | ||
) |
Compute the mean and variance from a sparse objective vector. This uses the standard two-pass algorithm with naive accumulation of the sum of squared differences; thus, it is best used with a sufficiently high-precision Output_
like double
.
Output_ | Type of the output data. |
Value_ | Type of the input data. |
Index_ | Type of the row/column indices. |
[in] | value | Pointer to an array of length num , containing the values of the structural non-zeros. |
num_nonzero | Length of the array pointed to by value . | |
num_all | Length of the objective vector, including the structural zeros not in value . This should be greater than or equal to num_nonzero . | |
skip_nan | See Options::skip_nan . |
value
. std::pair< Output_, Output_ > tatami_stats::variances::direct | ( | const Value_ * | ptr, |
Index_ | num, | ||
bool | skip_nan | ||
) |
Compute the mean and variance from a dense objective vector. This uses the standard two-pass algorithm with naive accumulation of the sum of squared differences; thus, it is best used with a sufficiently high-precision Output_
like double
.
Output_ | Type of the output data. |
Value_ | Type of the input data. |
Index_ | Type of the row/column indices. |
[in] | ptr | Pointer to an array of length num , containing the values of the objective vector. |
num | Length of the objective vector, i.e., length of the array at ptr . | |
skip_nan | See Options::skip_nan . |
[ptr, ptr + num)
. This may be NaN if there are not enough (non-NaN) values in ptr
. void tatami_stats::variances::apply | ( | bool | row, |
const tatami::Matrix< Value_, Index_ > * | p, | ||
Output_ * | output, | ||
const Options & | vopt | ||
) |
Compute variances for each element of a chosen dimension of a tatami::Matrix
. 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
.
Value_ | Type of the matrix value, should be numeric. |
Index_ | Type of the row/column indices. |
Output_ | Type of the output value. |
row | Whether to compute the variance for each row. If false, the variance is computed for each column instead. | |
p | Pointer to a tatami::Matrix . | |
[out] | output | Pointer 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 variances. |
vopt | Variance calculation options. |
std::vector< Output_ > tatami_stats::variances::by_column | ( | const tatami::Matrix< Value_, Index_ > * | p, |
const Options & | vopt | ||
) |
Wrapper around apply()
for column variances.
Output_ | Type of the output value. |
Value_ | Type of the matrix value, should be numeric. |
Index_ | Type of the row/column indices. |
p | Pointer to a tatami::Matrix . |
vopt | Variance calculation options. |
std::vector< Output_ > tatami_stats::variances::by_column | ( | const tatami::Matrix< Value_, Index_ > * | p | ) |
Overload with default options.
Output_ | Type of the output value. |
Value_ | Type of the matrix value, should be numeric. |
Index_ | Type of the row/column indices. |
p | Pointer to a tatami::Matrix . |
std::vector< Output_ > tatami_stats::variances::by_row | ( | const tatami::Matrix< Value_, Index_ > * | p, |
const Options & | vopt | ||
) |
Wrapper around apply()
for column variances.
Output_ | Type of the output value. |
Value_ | Type of the matrix value, should be numeric. |
Index_ | Type of the row/column indices. |
p | Pointer to a tatami::Matrix . |
vopt | Variance calculation options. |
std::vector< Output_ > tatami_stats::variances::by_row | ( | const tatami::Matrix< Value_, Index_ > * | p | ) |
Overload with default options.
Output_ | Type of the output value. |
Value_ | Type of the matrix value, should be numeric. |
Index_ | Type of the row/column indices. |
p | Pointer to a tatami::Matrix . |