Caculating Correlation for CPA attack on AES I am having some trouble understanding how to calculate the correlation coefficient for CPA attack on AES. 

In the article Study of Deep Learning Techniques for Side-Channel Analysis and Introduction to ASCAD Database, they actually keep 700 measurements for the computation of 1 SBox (page 11), in step 7 of the algorithm (page 12).

But when we want to calculate the hamming distance between the input and output of that computation for a guessed subkey, we will get a single value representing the distance. So how will we calculate the coefficient between the measurements and the hamming distance? Since we have 700 measurements for the same instruction, but only one hamming distance.
Premise: I'm not familiar with the paper.

You probably compute 700 correlation values, one for each time sample.

For CPA you need several ($N$) traces, with different/random input but fixed key. Here each trace is made by 700 samples, each sample correspond to a different time instant.

Regarding the hypothesis, we have the HD computation which will depend on the plaintext and the key. The attacker knows the plaintext but not the key so she guesses all key values.

You put the traces in a matrix where the $N$ rows are the different acquisitions (each with a different plaintext) and the columns are the 700 time instants.
You create a second matrix with $N$ rows and 256 columns, where each entry is HD relative to the plaintext of the row and the key of the column.

Then you correlate each column of the first matrix with each column of the second matrix.
You will obtain as result 256 traces with 700 time instant, each showing the correlation of key guess $i$-th ($0&lt;i&lt;256$) at the $j$-th ($0&lt;j&lt;700$) time instant.

You don't expect all the time samples to leak in the same way, so you might have high correlation, with the correct key, only on one or few samples.