code: function sample_covariance(x, y) {
  
          // The two datasets must have the same length which must be more than 1
          if (x.length <= 1 || x.length != y.length){
              return null;
          }
  
          // determine the mean of each dataset so that we can judge each
          // value of the dataset fairly as the difference from the mean. this
          // way, if one dataset is [1, 2, 3] and [2, 3, 4], their covariance
          // does not suffer because of the difference in absolute values
          var xmean = mean(x),
              ymean = mean(y),
              sum = 0;
  
          // for each pair of values, the covariance increases when their
          // difference from the mean is associated - if both are well above
          // or if both are well below
          // the mean, the covariance increases significantly.
          for (var i = 0; i < x.length; i++){
              sum += (x[i] - xmean) * (y[i] - ymean);
          }
  
          // the covariance is weighted by the length of the datasets.
          return sum / (x.length - 1);
      }
docs: # [covariance](http://en.wikipedia.org/wiki/Covariance)  sample covariance of two datasets: how much do the two datasets move together? x and y are two datasets, represented as arrays of numbers.  depends on `mean()`