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

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

Detailed Description

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

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.

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

Constructor & Destructor Documentation

◆ RunningSparse()

template<typename Output_ , typename Value_ , typename Index_ >
tatami_stats::variances::RunningSparse< Output_, Value_, Index_ >::RunningSparse ( Index_  num,
Output_ *  mean,
Output_ *  variance,
bool  skip_nan,
Index_  subtract = 0 
)
inline
Parameters
numNumber of objective vectors.
[out]meanPointer 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]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.
subtractOffset 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.

Member Function Documentation

◆ add()

template<typename Output_ , typename Value_ , typename Index_ >
void tatami_stats::variances::RunningSparse< Output_, Value_, Index_ >::add ( const Value_ *  value,
const Index_ *  index,
Index_  number 
)
inline

Add the next observed vector to the variance calculation.

Parameters
[in]valueValue of structural non-zero elements.
[in]indexIndex of structural non-zero elements.
numberNumber of non-zero elements in value and index.

◆ finish()

template<typename Output_ , typename Value_ , typename Index_ >
void tatami_stats::variances::RunningSparse< 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: