covarp

Syntax

covarp(X, Y)

Details

Calculates the population covariance of X and Y.

Parameters

X and Y are scalars/vectors/matrices/tables of the same size. If X is a table, only the numeric columns are calculated.

Returns

  • When both X and Y are scalars or vectors of equal length, a DOUBLE scalar is returned.
  • When either X or Y is a matrix, a DOUBLE vector is returned.
  • When either X or Y is a table, a table is returned.

Examples

x = [100, 100, 100, 1100]
y = [0.98, 0.95, 0.92, 0.88]
covarp(x,y);

// output: -13.13

x=matrix([0.010,  0.012, -0.005, 0.008], [0.009,  0.011, -0.004, 0.007], [0.011,  0.013, -0.006, 0.009])
y=[0.008, 0.010, -0.003, 0.006]
covarp(x,y)

// output: 3

Related Function: covar