Statistics: cholcov

### Function Reference: `cholcov`

statistics: T = cholcov (sigma)
statistics: [T, p = cholcov (sigma)
statistics: […] = cholcov (sigma, flag)

Cholesky-like decomposition for covariance matrix.

`T = cholcov (sigma)` computes matrix T such that sigma = T’ T. sigma must be square, symmetric, and positive semi-definite.

If sigma is positive definite, then T is the square, upper triangular Cholesky factor. If sigma is not positive definite, T is computed with an eigenvalue decomposition of sigma, but in this case T is not necessarily triangular or square. Any eigenvectors whose corresponding eigenvalue is close to zero (within a tolerance) are omitted. If any remaining eigenvalues are negative, T is empty.

The tolerance is calculated as `10 * eps (max (abs (diag (sigma))))`.

`[T, p = cholcov (sigma)` returns in p the number of negative eigenvalues of sigma. If p > 0, then T is empty, whereas if p = 0, sigma) is positive semi-definite.

If sigma is not square and symmetric, P is NaN and T is empty.

`[T, p = cholcov (sigma, 0)` returns p = 0 if sigma is positive definite, in which case T is the Cholesky factor. If sigma is not positive definite, p is a positive integer and T is empty.

`[…] = cholcov (sigma, 1)` is equivalent to `[…] = cholcov (sigma)`.

See also: chov

Source Code: cholcov

### Example: 1

     C1 = [2, 1, 1, 2; 1, 2, 1, 2; 1, 1, 2, 2; 2, 2, 2, 3]
     T = cholcov (C1)
     C2 = T'*T

    C1 =

       2   1   1   2
       1   2   1   2
       1   1   2   2
       2   2   2   3

    T =

      -0.1247  -0.6365   0.7612        0
       0.8069  -0.5114  -0.2955        0
       1.1547   1.1547   1.1547   1.7321

    C2 =

       2   1   1   2
       1   2   1   2
       1   1   2   2
       2   2   2   3