tatami_stats
Matrix statistics for tatami
|
Running variances from sparse data. More...
#include <variances.hpp>
Public Member Functions | |
RunningSparse (Index_ num, Output_ *mean, Output_ *variance, bool skip_nan, Index_ subtract=0) | |
void | add (const Value_ *value, const Index_ *index, Index_ number) |
void | finish () |
Running variances from sparse data.
Compute running means and variances from sparse data using Welford's method. This does the same as RunningDense
but for sparse observed vectors.
Output_ | Type of the output data. |
Value_ | Type of the input data. |
Index_ | Type of the row/column indices. |
|
inline |
num | Number of objective vectors. | |
[out] | mean | Pointer to an output array of length num , containing the means for each objective vector. This should be zeroed on input; after finish() is called, this will contain the mean for each objective vector. |
[out] | variance | Pointer to an output array of length num , containing the variances for each objective vector. This should be zeroed on input; after finish() is called, this will contain the sample variance for each objective vector. |
skip_nan | See Options::skip_nan for details. | |
subtract | Offset to subtract from each element of index before using it to index into mean and friends. Only relevant if mean and friends hold statistics for a contiguous subset of objective vectors, e.g., during task allocation for parallelization. |
|
inline |
Add the next observed vector to the variance calculation.
[in] | value | Value of structural non-zero elements. |
[in] | index | Index of structural non-zero elements. |
number | Number of non-zero elements in value and index . |
|
inline |
Finish the variance calculation once all observed vectors have been passed to add()
.