tatami_stats
Matrix statistics for tatami
Loading...
Searching...
No Matches
Public Member Functions | List of all members
tatami_stats::variances::RunningDense< Output_, Value_, Index_ > Class Template Reference

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 ()
 

Detailed Description

template<typename Output_, typename Value_, typename Index_>
class tatami_stats::variances::RunningDense< Output_, Value_, Index_ >

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.

Template Parameters
Output_Type of the output data.
Value_Type of the input data.
Index_Type of the row/column indices.

Constructor & Destructor Documentation

◆ RunningDense()

template<typename Output_ , typename Value_ , typename Index_ >
tatami_stats::variances::RunningDense< Output_, Value_, Index_ >::RunningDense ( Index_  num,
Output_ *  mean,
Output_ *  variance,
bool  skip_nan 
)
inline
Parameters
numNumber of objective vectors, i.e., \(n\).
[out]meanPointer 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]variancePointer 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_nanSee Options::skip_nan for details.

Member Function Documentation

◆ add()

template<typename Output_ , typename Value_ , typename Index_ >
void tatami_stats::variances::RunningDense< Output_, Value_, Index_ >::add ( const Value_ *  ptr)
inline

Add the next observed vector to the variance calculation.

Parameters
[in]ptrPointer to an array of values of length num, corresponding to an observed vector.

◆ finish()

template<typename Output_ , typename Value_ , typename Index_ >
void tatami_stats::variances::RunningDense< Output_, Value_, Index_ >::finish ( )
inline

Finish the variance calculation once all observed vectors have been passed to add().


The documentation for this class was generated from the following file: