tatami_stats
Matrix statistics for tatami
|
Running variances from dense data. More...
#include <variances.hpp>
Public Member Functions | |
RunningDense (Index_ num, Output_ *mean, Output_ *variance, bool skip_nan) | |
void | add (const Value_ *ptr) |
void | finish () |
Running variances from dense data.
Compute running means and variances from dense data using Welford's method. This considers a scenario with a set of equilength "objective" vectors \([v_1, v_2, v_3, ..., v_n]\), but data are only available for "observed" vectors \([p_1, p_2, p_3, ..., p_m]\), where the \(j\)-th element of \(p_i\) is the \(i\)-th element of \(v_j\). The idea is to repeatedly call add()
for ptr
corresponding to observed vectors from 0 to \(m - 1\), and then finally call finish()
to obtain the mean and variance for each objective vector.
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, i.e., \(n\). | |
[out] | mean | Pointer to an output array of length num . This should be zeroed on input; after finish() is called, this will contain the means 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. |
|
inline |
Add the next observed vector to the variance calculation.
[in] | ptr | Pointer to an array of values of length num , corresponding to an observed vector. |
|
inline |
Finish the variance calculation once all observed vectors have been passed to add()
.