# corr() Function & Examples

Use the corr() statistics function in Calcul.io. Review its syntax, edit working examples, understand the result, and explore related math functions.

## corr

#### corr(A,B)

Try it yourself:

```calculio
corr([2, 4, 6, 8],[1, 2, 3, 6])
corr(matrix([[1, 2.2, 3, 4.8, 5], [1, 2, 3, 4, 5]]), matrix([[4, 5.3, 6.6, 7, 8], [1, 2, 3, 4, 5]]))
```

[max](https://calcul.io/function/max/index.md)

[mean](https://calcul.io/function/mean/index.md)

[min](https://calcul.io/function/min/index.md)

[median](https://calcul.io/function/median/index.md)

[min](https://calcul.io/function/min/index.md)

[prod](https://calcul.io/function/prod/index.md)

[std](https://calcul.io/function/std/index.md)

[sum](https://calcul.io/function/sum/index.md)

---

## Measure linear association with corr

**corr(A, B)** calculates the correlation between two equally sized data sets. Correlation summarizes whether values tend to rise and fall together: a positive result suggests they move in the same direction, a negative result suggests opposite movement, and a result near zero indicates little linear association.

## Reading the result

Pearson correlation lies between -1 and 1. A value of 1 represents a perfect positive linear relationship, while -1 represents a perfect negative one. Correlation is unitless, so it is useful for comparing variables with different scales. For the related spread measures, see [mean](https://calcul.io/function/mean/index.md), [standard deviation](https://calcul.io/function/std/index.md), and [variance](https://calcul.io/function/variance/index.md).

## Practical example

Use `corr([1,2,3,4], [2,4,6,8])` to confirm a perfectly positive linear pattern. In real measurements, first remove missing or nonnumeric entries and make sure that positions correspond: the first value of A must describe the same observation as the first value of B. [filter](https://calcul.io/function/filter/index.md) and [subset](https://calcul.io/function/subset/index.md) can help prepare aligned data.

## Important caveats

Correlation does not show causation and can be misleading when an outlier dominates a small sample. It measures linear rather than every possible relationship; curved data can have a low correlation even when clearly related. The inputs must have compatible lengths and enough varying numeric values—correlation is not meaningful when either series has zero spread. Use [median](https://calcul.io/function/median/index.md) and [mad](https://calcul.io/function/mad/index.md) to explore robust summaries alongside it.

[All functions](https://calcul.io/functions/index.md)
