Loading TOC...


   $values as cts.reference[],
   [$options as String[]],
   [$query as cts.query?],
   [$forest-ids as String[]]
) as math.linearModel?


Returns a linear model that fits the frequency-weighted data set. The input data is a co-occurrence, formed from the specified value lexicons. The length of the input lexicon sequence should be 2, as currently only simple linear regression model is supported. The first lexicon should be the value of the dependent variable while the other lexicon should be the value of the independent variable. This function works like math:linear-model except each pair in the input lexicons is counted cts:frequency times. This function performs the calculation in parallel in all data nodes then aggregates the values.

$values References to two range indexes. The types of the range indexes must be numeric. If the size of this sequence is not 2, the function returns the empty sequence.
$options Same as the "options" parameter in cts:aggregate.
$query Same as the "query" parameter in cts:aggregate.
$forest-ids Same as the "forest-ids" parameter in cts:aggregate.


//   This query assumes range indexes of type unsignedLong
//   with positions are configured in the database for both
//   xval and yval. It generates some sample data and then
//   performs the aggregation in a separate transaction.

//  Generate data:
for (x=1; x<11; x++) {
  var j = 2 * x + 1;
  var uri = fn.concat(x, ".json");
  var vals = {xval:x, yval:j}
  var obj = {a:vals};
  xdmp.documentInsert(uri, obj);

// Run the following query:

    [cts.jsonPropertyReference("yval", ["type=unsignedLong"]),
     cts.jsonPropertyReference("xval", ["type=unsignedLong"])],

  <math:linear-model intercept="0.352941176470588" 
      coefficients="1.97058823529412" rsquared="0.995196571090748" 


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