<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/math.linearModel.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>math.linearModel</api:function-name><api:suggest>math.linearmodel</api:suggest><api:suggest>math</api:suggest><api:suggest>linearmodel</api:suggest><api:function-link mode="xquery" fullname="math:linear-model">/apidoc/8.0/math:linear-model.xml</api:function-link><api:function mode="javascript" name="linearModel" type="builtin" lib="math" category="MathBuiltins" hidden="false" bucket="MarkLogic Built-In Functions" prefix="math" namespace="http://marklogic.com/xdmp/math" fullname="math.linearModel"><api:summary>
  <p xmlns="http://www.w3.org/1999/xhtml">Returns a linear model that fits the given data set. The size of the input
  array should be 2, as currently only simple linear regression model is
  supported. The first element of the array should be the value of the
  dependent variable while the other element should be the value of the
  independent variable.</p>
  <p xmlns="http://www.w3.org/1999/xhtml">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 independent variable is 0,
  the function returns a linear model with intercept = the mean of the
  dependent variable, coefficients = NaN and r-squared = NaN. After the
  elimination, if the standard deviation of the dependent variable is 0,
  the function returns a linear model with r-squared = NaN.</p>
  <p xmlns="http://www.w3.org/1999/xhtml">For the version of this function that uses Range Indexes, see
  <a href="./cts:linear-model">cts:linear-model</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.
  </api:param-description><api:param-name>arg</api:param-name><api:param-type>Array[]</api:param-type></api:param></api:params><api:return>math.linearModel?</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 + 1;
  x.push(j, i);
  arr.push(x); };
math.linearModel(arr);
=&gt;
math:linear-model(
  &lt;math:linear-model intercept="1" coefficients="2" rsquared="1"
        xmlns:xs="http://www.w3.org/2001/XMLSchema" 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:math="http://marklogic.com/xdmp/math"/&gt;)
</pre></api:example></api:function></api:function-page>