Version:

Loading TOC...

MarkLogic Server 11.0 Product Documentation

math.correlationmath.correlation( arg as Array[] ) as Number?

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.

Parameters | |
---|---|

arg | The input data set. Each array should contain a pair of values. |

var arr = new Array(); for (i=1; i < 11; i++) { var x = new Array(); var j = 2 * i; x.push(i, j); arr.push(x); }; math.correlation(arr); => 1

Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.