# Covariance (covariance)

The sample covariance of two lists of the same length.

## How to write it

### covariance(xs, ys)

The sum of the products of the deviations from the means, divided by n - 1.

**xs**

The first list. Takes a list.

**ys**

The second list, as long as the first. Takes a list.

## Examples

- $\displaystyle \operatorname{covariance}(\left[ 1, 2, 3, 4 \right], \left[ 2, 4, 5, 9 \right]) = \frac{11}{3}$

  `covariance([1, 2, 3, 4], [2, 4, 5, 9])`

  In the solver, `covariance([1, 2, 3, 4], [2, 4, 5, 9])` gives `11/3`.

  [Open in the solver](https://hilberon.com/?q=covariance%28%5B1%2C%202%2C%203%2C%204%5D%2C%20%5B2%2C%204%2C%205%2C%209%5D%29)

## Related functions

- [cvar](https://hilberon.com/library/cvar)

  The conditional value at risk of a loss: its expected value over the worst share 1 - level.
- [correlation](https://hilberon.com/library/correlation)

  The correlation coefficient of two lists of the same length.
- [distributed](https://hilberon.com/library/distributed)

  A variable and the distribution it follows, as probability and expectation read it.
- [cdf](https://hilberon.com/library/cdf)

  The probability that a variable with a distribution is at most a value.
- [expectation](https://hilberon.com/library/expectation)

  The expected value of an expression of a variable with a distribution or a process.
- [binomial_distribution](https://hilberon.com/library/binomial_distribution)

  The number of successes in n independent trials that each succeed with chance p.

---
Source: https://hilberon.com/library/covariance
