You can define a distance metric for two vectors A and B of length N containing numbers in the interval [-1, 1], for example. a
sum = 0 for i in 0 to 99: d = (A[i] - B[i])^2 // this is in range 0 .. 4 sum = (sum / 4) / N // now in range 0 .. 1
Now this returns a distance of 1 for vectors that are completely opposite (one is all 1, the other is -1) and 0 for identical vectors.
You can translate this into your ratio by
coeff = 1 - sum
However, this is a crude approach because it does not take into account the fact that there may be horizontal distortions or a shift between the signals you want to compare, so let's look at some approaches to dealing with this.
You can sort both arrays (for example, in ascending order), and then calculate the distance / coefficient. This returns more similarities than the original metric, and is agnostic for permutations / shifts of the signal.
You can also calculate the differentials and calculate the distance / coefficient for them, and then you can do it sorted as well. The use of differentials has the advantage of eliminating vertical shifts. Sorted differentials eliminate horizontal shift, but still recognize different shapes better than sorted data source points.
You can then, for example, average odds. Here's a more complete code. In the procedure below, the coefficient for arrays A and B of a given size is calculated and first d different differentials are taken (recursively). If sorted correctly, the final (differentiated) array is sorted.
procedure calc(A, B, size, d, sorted): if (d > 0): A' = new array[size - 1] B' = new array[size - 1] for i in 0 to size - 2: A'[i] = (A[i + 1] - A[i]) / 2 // keep in range -1..1 by dividing by 2 B'[i] = (B[i + 1] - B[i]) / 2 return calc(A', B', size - 1, d - 1, sorted) else: if (sorted): A = sort(A) B = sort(B) sum = 0 for i in 0 to size - 1: sum = sum + (A[i] - B[i]) * (A[i] - B[i]) sum = (sum / 4) / size return 1 - sum
For something completely different, you can also start the Fourier transform using FFT, and then take the distance metric over the returning spectra.