# Pearson Correlation Vs. Z-normalized Euclidean Distance

It is [well understood](https://arxiv.org/pdf/1601.02213.pdf) that the z-normalized Euclidean distance, $ED_{z-norm}$, and the Pearson correlation, $PC$, between any two subsequences with length $m$ share the following relationship:

$ED_{z-norm} = \sqrt {2 * m * (1 - PC)}$

Naturally, when the two subsequences are perfectly correlated (i.e., $PC = 1$), then we get:

\begin{align}
    ED_{z-norm} ={}&
        \sqrt {2 * m * (1 - PC)}
    \\
    ={}&
        \sqrt {2 * m * (1 - 1)}
    \\
    ={}&
        \sqrt {2 * m * 0}
    \\
    ={}&
        \sqrt {0}
    \\
    ={}&
        0
    \\
\end{align}

Similarly, when the two subsequences are completely uncorrelated (i.e., $PC = 0$), then we get:

\begin{align}
    ED_{z-norm} ={}&
        \sqrt {2 * m * (1 - PC)}
    \\
    ={}&
        \sqrt {2 * m * (1 - 0)}
    \\
    ={}&
        \sqrt {2 * m * 1}
    \\
    ={}&
        \sqrt {2 * m}
    \\
\end{align}

In other words, the largest possible z-normalized distance between any pair of subsequences with length $m$ is $\sqrt{2 * m}$. The maximum distance can never be bigger!

Finally, when two subsequences are anti-correlated (i.e., $PC = -1$), then we get:

\begin{align}
    ED_{z-norm} ={}&
        \sqrt {2 * m * (1 - PC)}
    \\
    ={}&
        \sqrt {2 * m * (1 - (-1))}
    \\
    ={}&
        \sqrt {2 * m * 2}
    \\
    ={}&
        \sqrt {4 * m}
    \\
    ={}&
        2 * \sqrt {m}
    \\
\end{align}


```python

```

0b5cbab1825e9e60847d65fba2eebff969dc282e
ipynb
Jupyter Notebook
docs/Pearson.ipynb
profintegra/stumpy
66b3402d91820005b466e1da6fe353b61e6246c5
BSD-3-Clause
2019-05-03T19:26:39.000Z
2022-03-31T20:42:08.000Z
docs/Pearson.ipynb
profintegra/stumpy
66b3402d91820005b466e1da6fe353b61e6246c5
BSD-3-Clause
2019-05-06T14:14:01.000Z
2022-03-31T20:39:31.000Z
docs/Pearson.ipynb
profintegra/stumpy
66b3402d91820005b466e1da6fe353b61e6246c5
BSD-3-Clause
2019-05-04T01:36:05.000Z
2022-03-31T20:31:11.000Z
Qwen/Qwen-72B
1. YES
2. YES