Loading TOC...

math.covariance

math.covariance(
   $arg as Array[]
) as Number?

Summary

Returns the sample covariance of a data set. The size of the input array should be 2. The function eliminates all pairs for which either the first element or the second element is empty. After the elimination, if the length of the input is less than 2, the function returns the empty sequence.

For the version of this that uses range indexes, see cts.covariance.

Parameters
$arg The input data set. Each array should contain a pair of values. Use xdmp.arrayValues to produce a sequence of array values (as a ValueIterator).

Example

var arr = new Array();
for (i=1; i < 11; i++) { 
  var x = new Array();
  var j = 2 * i;
  x.push(i, j);
  arr.push(x); };
math.covariance(arr);


  => 18.3333333333333

Comments

    Powered by MarkLogic Server 7.0-4.1 and rundmc | Terms of Use | Privacy Policy