<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/math.correlation.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>math.correlation</api:function-name><api:suggest>math.correlation</api:suggest><api:suggest>math</api:suggest><api:suggest>correlation</api:suggest><api:function-link mode="xquery" fullname="math:correlation">/apidoc/8.0/math:correlation.xml</api:function-link><api:function mode="javascript" name="correlation" type="builtin" lib="math" category="MathBuiltins" hidden="false" bucket="MarkLogic Built-In Functions" prefix="math" namespace="http://marklogic.com/xdmp/math" fullname="math.correlation"><api:summary>
  Returns the Pearson correlation coefficient 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. After the elimination, if the standard deviation
  of the first column or the standard deviation of the second column is 0,
  the function returns the empty sequence.
</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.
  </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.correlation(arr);

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