Loading TOC...

cts.stddevP

cts.stddevP(
   $range-index as cts.reference,
   [$options as String[]],
   [$query as cts.query?],
   [$forest-ids as String[]]
) as Number?

Summary

Returns a frequency-weighted standard deviation of the population given a value lexicon. This function works like math:stddev-p except each item in the lexicon is counted cts:frequency times. This function performs the calculation in parallel in all data nodes then aggregates the values. The function returns the empty sequence if the lexicon contains no value.

Parameters
$range-index Reference to a range index. The type of the range index must be numeric.
$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.

Example

//   This query assumes an int range index
//   is configured in the database. It
//   generates some sample data and then
//   performs the aggregation in a separate
//   transaction.

declareUpdate();

for (x=1; x<11; x++) {
  var o = new Object();
  o.int = [];
  for (y=x; y<11; y++) {
    o.int.push(y);
  };
  xdmp.documentInsert((x + ".json"), o);
};

*******
// Then run the following (requires int range index on int):

var item = cts.stddevP(
  cts.jsonPropertyReference("int","type=int"),
    ["item-frequency","concurrent"]);
var frag = cts.stddevP(
  cts.jsonPropertyReference("int","type=int"),
    ["fragment-frequency","concurrent"]);
var res = new Array();
res.push(item);
res.push(frag);
res;
=>
[2.44948974278318, 2.44948974278318]

Comments

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