corr

corr(A,B)

Try it yourself:


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, standard deviation, and variance.

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 and subset 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 and mad to explore robust summaries alongside it.

Try Corr in Calcul.io

Start with one of the editable examples above, then replace its arguments with your own values. Keeping the function on a separate calculator line makes the input and result easy to compare. For a longer workflow, assign the result to a variable or reference that line in the next expression.

Check the shown signature before adding optional arguments, and use the related-function links to compare operations with similar purposes.

All functions