Z-Normalized Euclidean Distance Derivation I am going through this paper:
http://www.cs.ucr.edu/~eamonn/PID4481997_extend_Matrix%20Profile_I.pdf
And on Page 4, it is claimed that the squared z-normalized euclidean distance between two vectors of equal length, Q and T[i], (the latter of which is just the ith subsequence of a longer 1D array, T) can be calculated from:

Here, m is the length of Q (or T[i]), mu_Q is the mean of Q, M_T[i] is the mean for the ith subsequence of T, sigma_Q is the standard deviation of Q, sigma_T[i] is the standard deviation for the ith subsequence of T, and Q.T[i] is the dot product between Q and T[i].
I am attempting to derive this equation from first principals but can't see to reconcile the final steps:

In this case, the summation loops through each element of either T[i] or Q. Also, recall that:

I've gotten as close as this but it's not quite right:

A semi-related question is here.
 A: Here's a straightforward way. Let $\mathbf u$ and $\mathbf v$ be $m$-vectors. 
Let  $\mu_1=\frac 1m\sum_{k=1}^m u_k$ and $\mu_2=\frac 1m\sum_{k=1}^m v_k$ denote their means.
Let  $\sigma_1^2=\frac 1m\sum_{k=1}^m (u_k-\mu_1)^2$ and $\sigma_2^2=\frac 1m\sum_{k=1}^m (v_k-\mu_2)^2$ denote their standard deviations. This rewrites as $\sigma_1^2=\frac 1m\left|\left| \mathbf u-\mu_1\mathbf 1   \right| \right|^2$, hence $m=\left| \left| \frac{\mathbf u-\mu_1\mathbf 1}{\sigma_1} \right| \right|^2=\left| \left| \frac{\mathbf v-\mu_2\mathbf 1}{\sigma_2} \right| \right|^2$
The squared $z$-normalized Euclidean distance between $\mathbf u$ and $\mathbf v$  is $$\begin{align}\left|\left|\frac{\mathbf u-\mu_1\mathbf 1}{\sigma_1} -\frac{\mathbf v-\mu_2\mathbf 1}{\sigma_2}\right|\right|^2
&= \left| \left| \frac{\mathbf u-\mu_1\mathbf 1}{\sigma_1} \right| \right|^2+\left| \left| \frac{\mathbf v-\mu_2\mathbf 1}{\sigma_2} \right| \right|^2 -\frac{2}{\sigma_1 \sigma_2} \langle \mathbf u-\mu_1\mathbf 1, \mathbf v-\mu_2\mathbf 1\rangle \\
&= 2m-\frac{2}{\sigma_1 \sigma_2} \left(\langle \mathbf u,\mathbf v \rangle-\mu_2 \sum_{k=1}^mu_k -\mu_1 \sum_{k=1}^mv_k + \mu_1 \mu_2m  \right)\\
&=2m-\frac{2}{\sigma_1 \sigma_2} \left(\langle \mathbf u,\mathbf v\rangle -\mu_2m\mu_1 - \mu_1m\mu_2+\mu_1 \mu_2m \right)\\
&=2m \left(1-\frac{1}{m\sigma_1 \sigma_2}\left(\langle \mathbf u,\mathbf v\rangle -m\mu_1\mu_2\right) \right)
\end{align}
$$
A: I research the MP paper 1 and 2. And I know your pain !!

