vstat

Functions

int main(int argc, char *argv[])

vstat [ option ] [ infile ]

  • -l int

    • length of vector \((1 \le L)\)

  • -m int

    • order of vector \((0 \le L - 1)\)

  • -t int

    • output interval \((1 \le T)\)

  • -c double

    • confidence level \((0 < C < 100)\)

  • -o int

    • output format

      • 0 mean and covariance

      • 1 mean

      • 2 covariance

      • 3 standard deviation

      • 4 correlation

      • 5 precision

      • 6 mean and lower/upper bounds

  • -d bool

    • output only diagonal elements

  • infile str

    • double-type vectors

  • stdout

    • double-type statistics

The input of this command is

\[ \begin{array}{cccc} \underbrace{ \underbrace{x_1(1), \; \ldots, \; x_1(L)}_L, \; \ldots, \; \underbrace{x_T(1), \; \ldots, \; x_T(L)}_L, }_{L \times T} \; \ldots, \end{array} \]
and the output format depends on -o option.

If \(O=1\),

\[ \begin{array}{ccc} \underbrace{\mu_{0}(1), \; \ldots, \; \mu_{0}(L)}_L, & \underbrace{\mu_{T}(1), \; \ldots, \; \mu_{T}(L)}_L, & \ldots, \end{array} \]
where
\[ \mu_t(l) = \frac{1}{T} \sum_{\tau=1}^T x_{t+\tau}(l). \]

If \(O=2\),

\[ \begin{array}{cc} \underbrace{\sigma^2_0(1,1), \; \sigma^2_{0}(1,2), \; \ldots, \; \sigma^2_0(L,L)}_{L \times L}, & \ldots, \end{array} \]
where
\[ \sigma^2_t(k,l) = \frac{1}{T} \sum_{\tau=1}^T (x_{t+\tau}(k) - \mu_t(k)) (x_{t+\tau}(l) - \mu_t(l)). \]

If \(O=3\),

\[ \begin{array}{cc} \underbrace{\sigma_{0}(1,1), \; \sigma_{0}(2,2), \; \ldots, \; \sigma_{0}(L,L)}_L, & \ldots \end{array} \]

If \(O=4\),

\[ \begin{array}{cc} \underbrace{r_{0}(1,1), \; r_{0}(1,2), \; \ldots, \; r_{0}(L,L)}_{L \times L}, & \ldots, \end{array} \]
where
\[ r_t(k,l) = \frac{\sigma^2_t(k,l)}{\sigma_t(k,k) \, \sigma_t(l,l)}. \]

If \(O=5\),

\[ \begin{array}{cc} \underbrace{s_{0}(1,1), \; s_{0}(1,2), \; \ldots, \; s_{0}(L,L)}_{L \times L}, & \ldots, \end{array} \]
where \(s_t(k,l)\) is the \((k,l)\)-th component of the inverse of the covariance matrix \(\{\sigma^2_t(k,l)\}_{k,l=1}^L\).

If \(O=6\),

\[ \begin{array}{ccc} \underbrace{\mu_{0}(1), \; \ldots, \; \mu_{0}(L)}_L, & \underbrace{\ell_{0}(1), \; \ldots, \; \ell_{0}(L)}_L, & \underbrace{u_{0}(1), \; \ldots, \; u_{0}(L)}_L, & \ldots, \end{array} \]
where
\[\begin{split}\begin{eqnarray} \ell_t(l) &=& \mu_t(l) - p(C, L-1) \sqrt{\frac{\sigma^2_t(l,l)}{L-1}}, \\ u_t(l) &=& \mu_t(l) + p(C, L-1) \sqrt{\frac{\sigma^2_t(l,l)}{L-1}}, \end{eqnarray}\end{split}\]
and \(p(C, L-1)\) is the upper \((100-C)/2\)-th percentile of the of the t-distribution with degrees of freedom \(L-1\).

echo 0 1 2 3 4 5 6 7 8 9 | x2x +ad > data.d
vstat -o 1 data.d | x2x +da
# 4.5
vstat -o 1 data.d -t 5 | x2x +da
# 2, 7

Parameters
  • argc[in] Number of arguments.

  • argv[in] Argument vector.

Returns

0 on success, 1 on failure.

See also

vsum

class sptk::StatisticsAccumulation

Accumulate statistics.

The input of is an \(M\)-th order vector:

\[ \begin{array}{cccc} x_t(0), & x_t(1), & \ldots, & x_t(M). \end{array} \]
After running Run \(T\) times, the following statistics are obtained:
\[\begin{split}\begin{eqnarray} S_0 &=& T, \\ S_1(m) &=& \sum_{t=0}^{T-1} x_t(m), \\ S_2(m,n) &=& \sum_{t=0}^{T-1} x_t(m) x_t(n). \end{eqnarray}\end{split}\]
Then, the moments, e.g., mean and covariance, of the input data can be computed from the accumulated statistics \(\{S_k\}_{k=0}^K\).

Public Functions

StatisticsAccumulation(int num_order, int num_statistics_order)
Parameters
  • num_order[in] Order of vector, \(M\).

  • num_statistics_order[in] Order of statistics, \(K\).

inline int GetNumOrder() const
Returns

Order of vector.

inline int GetNumStatisticsOrder() const
Returns

Order of statistics.

inline bool IsValid() const
Returns

True if this object is valid.

bool GetNumData(const StatisticsAccumulation::Buffer &buffer, int *num_data) const
Parameters
  • buffer[in] Buffer.

  • num_data[out] Number of accumulated data.

Returns

True on success, false on failure.

bool GetSum(const StatisticsAccumulation::Buffer &buffer, std::vector<double> *sum) const
Parameters
  • buffer[in] Buffer.

  • sum[out] Summation of accumulated data.

Returns

True on success, false on failure.

bool GetMean(const StatisticsAccumulation::Buffer &buffer, std::vector<double> *mean) const
Parameters
  • buffer[in] Buffer.

  • mean[out] Mean of accumulated data.

Returns

True on success, false on failure.

bool GetDiagonalCovariance(const StatisticsAccumulation::Buffer &buffer, std::vector<double> *variance) const
Parameters
  • buffer[in] Buffer.

  • variance[out] Diagonal covariance of accumulated data.

Returns

True on success, false on failure.

bool GetStandardDeviation(const StatisticsAccumulation::Buffer &buffer, std::vector<double> *standard_deviation) const
Parameters
  • buffer[in] Buffer.

  • standard_deviation[out] Standard deviation of accumulated data.

Returns

True on success, false on failure.

bool GetFullCovariance(const StatisticsAccumulation::Buffer &buffer, SymmetricMatrix *full_covariance) const
Parameters
  • buffer[in] Buffer.

  • full_covariance[out] Full covariance of accumulated data.

Returns

True on success, false on failure.

bool GetUnbiasedCovariance(const StatisticsAccumulation::Buffer &buffer, SymmetricMatrix *unbiased_covariance) const
Parameters
  • buffer[in] Buffer.

  • unbiased_covariance[out] Unbiased covariance of accumulated data.

Returns

True on success, false on failure.

bool GetCorrelation(const StatisticsAccumulation::Buffer &buffer, SymmetricMatrix *correlation) const
Parameters
  • buffer[in] Buffer.

  • correlation[out] Correlation of accumulated data.

Returns

True on success, false on failure.

void Clear(StatisticsAccumulation::Buffer *buffer) const

Clear buffer.

Parameters

buffer[inout] Buffer.

bool Run(const std::vector<double> &data, StatisticsAccumulation::Buffer *buffer) const

Accumulate statistics.

Parameters
  • data[in] \(M\)-th order input vector.

  • buffer[inout] Buffer.

Returns

True on success, false on failure.

class Buffer

Buffer for StatisticsAccumulation class.