# staircase.Stairs.corr#

Stairs.corr(other, where=(<staircase.constants.NegInf object>, <staircase.constants.Inf object>), lag=0, clip='pre')#

Calculates either correlation, autocorrelation or cross-correlation.

All calculations are based off the Pearson correlation coefficient.

The calculation is between two step functions described by self and other. If lag is None or 0 then correlation is calculated, otherwise cross-correlation is calculated. Autocorrelation is a special case of cross-correlation when other is equal to self.

Parameters
other: :class:`Stairs`

the stairs instance with which to compute the correlation

wheretuple or list of length two, optional

Indicates the domain interval over which to perform the calculation. Default is (-sc.inf, sc.inf) or equivalently (None, None).

lagint, float, pandas.Timedelta

A pandas.Timedelta is only valid when domain is date-like.

clip{‘pre’, ‘post’}, default ‘pre’

Only relevant when lag is non-zero. Determines if the domain is applied before or after other is translated. If ‘pre’ then the domain over which the calculation is performed is the overlap of the original domain and the translated domain.

Returns
float

The correlation (or cross-correlation) between self and other

Examples

```>>> s1.corr(s2)
0.24687803791136045
```
```>>> s2.corr(s1)
0.24687803791136045
```
```>>> s1.corr(s2, where=(0, 6))
0.27500954910846337
```
```>>> # autocorrelation with lag 1
>>> s1.corr(s1, where=(1, 5), lag=1)
-0.8660254037844386
```
```>>> # cross-correlation with lag 1
>>> s1.corr(s2, where=(1, 5.5), lag=1)
0.4961389383568339
```
```>>> # cross-correlation with lag 1
>>> s1.corr(s2, where=(1, 4.5), lag=1, clip='post')
0.4961389383568339
```