<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/math.covariance.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>math.covariance</api:function-name><api:suggest>math.covariance</api:suggest><api:suggest>math</api:suggest><api:suggest>covariance</api:suggest><api:function-link mode="xquery" fullname="math:covariance">/apidoc/8.0/math:covariance.xml</api:function-link><api:function mode="javascript" name="covariance" type="builtin" lib="math" category="MathBuiltins" hidden="false" bucket="MarkLogic Built-In Functions" prefix="math" namespace="http://marklogic.com/xdmp/math" fullname="math.covariance"><api:summary>
  <p xmlns="http://www.w3.org/1999/xhtml">
  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.
  </p>
  <p xmlns="http://www.w3.org/1999/xhtml">For the version of this that uses range indexes, see 
  <a href="./cts.covariance" class="javascript">cts.covariance</a>.
  </p>
</api:summary><api:params><api:param name="arg" type="json:array*"><api:param-description>
  The input data set. Each array should contain a pair of values. 
  <span class="javascript" xmlns="http://www.w3.org/1999/xhtml">Use <a href="./xdmp.arrayValues">xdmp.arrayValues</a>
  to produce a sequence of array values (as a ValueIterator).</span>
  </api:param-description><api:param-name>arg</api:param-name><api:param-type>Array[]</api:param-type></api:param></api:params><api:return>Number?</api:return><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
var arr = new Array();
for (i=1; i &lt; 11; i++) { 
  var x = new Array();
  var j = 2 * i;
  x.push(i, j);
  arr.push(x); };
math.covariance(arr);


  =&gt; 18.3333333333333
</pre></api:example></api:function></api:function-page>