covariance, correlation
Calculates the covariance resp. correlation of two vectors (= sets containing numerals). Zero is returned if number of parameter elements is 0 or 1.
2
No. | Type | Description |
---|---|---|
1 input |
set of numerals | 1st vector |
2 input |
set of numerals | 2nd vector |
Type | Description |
---|---|
numeral | Result Calculated covariance resp. correlation |
Vectors have different lengths
sets provided contain non-numeric elements
echo( covariance( {},{} ) ); // Returns 0
echo( covariance( {10,20,30}, {10,30,20} ) ); // 50
echo( covariance( {10,20,30}, {30,20,10} ) ); // -100
echo( correlation( {1},{1} ) ); // 0
echo( correlation( {10,20,30}, {10,30,20} ) ); // 0.5
echo( correlation( {10,20,30}, {30,20,10} ) ); // -1
0
50
-100
0
0.5
-1