title: How to use var/variance function in armadillo
body: <p>How should I be using the var() function in armadillo ? </p>
  
  <p>I have a matrix in which rows are variables/features and columns observations/instances.</p>
  
  <p>I which to get the variance of each row so I can determine variables/features with the greatest variance. </p>
  
  <p>Currently I am calling:</p>
  
  <pre><code>auto variances = arma::var(data, 0, 1);
  </code></pre>
  
  <p>Where <code>data</code> is my matrix. </p>
  
  <p>As far as I can tell at the moment I am getting a matrix ? And the documentation suggests this is correct. I was expecting to get back a single vector with variance scores for each of my matrix rows. </p>
  
  <p>I can loop through my rows and get the variance for each row individually like so:</p>
  
  <pre><code>for (auto i = 0; i &lt; data.n_rows; ++i)
      auto rowVariance = arma::var(dataSet.data.row(i));
  </code></pre>
  
  <p>But I would prefer not to do this. </p>
  
  <p>I would like to get back a single vector containing variance values for each row in my matrix and then use arma::sort_index() on this vector to get a sorted set of indices corresponding to the sorted variances. </p>
  
  <p>Thanks in advance.  </p>