# Determine if two signals are the same?

I'm pretty new to signal processing. My data is the $(x,y,z)$ acceleration of someone walking with a smartphone in his/her pocket.

Goal

1. Given two signals, determine if it's from the same person twice, or if it's from two separate people.
2. Have some idea of the degree of confidence in the decision from 1.

Attempt

1. Segmented the data into the cyclic portions (each step and retraction of foot), and acyclic portions (maybe waiting between steps or when the user stops to talk to someone).

2. Calculate the statistics of the cyclic portions, and acyclic portions (mean, s.dev, median, cross correlation, time between each step and such).

Having said that, I lack the base knowledge for determining if two signals are 'similar' to one another which I'd imagine comes from some distance function. I've found ResearchGate thread but I was wondering if there's anything else that I should include (especially since my goals are not the same as that users). The methods they mention are:

• cross-correlation
• covariance
• mutual-information
• autocorrelation

My background is mostly stats / ML / software so I'd really appreciate it if any explanations were dumbed down!

• The correlation coefficient is often the first attempt at a similarity measure. Have you tried that? If so, what was the result? – AnonSubmitter85 Jan 10 '18 at 5:21
• I have not yet done so. The thing is I'm not 100% sure what I want so I was going to code up the whole kitchen sink and use those as features for something to automatically tune what distance measure to use – user49593 Jan 11 '18 at 14:16

Valuable results can be obtained using Mel Frequency Cepstral Coefficients (MFCC) and Dynamic Time Warping (DTW).

Divide the signal in multiple segments. I recommend to use an overlap of 50%. Compute the MFCCs for each frame, then you will obtain a vector of MFCCs for each frame. Finally you will have a matrix of [No of MFFCs, Number of frames], for each signal. To compare the similarity between sequences with different time length, compute the Euclidean distance between the two matrices. Also you can use the standardized Euclidean distance (check scipy.spatial.distance.cdist for Python).

cost_matrix = cdist(x, y, metric='euclidean')


Thus, you will obtain a cost matrix. Applying the DTW algorithm on this cost matrix, you will find the score which will tell you the similarity between the input signals. I recommend you to see how a different number of MFCCs affects the results and also take in consideration the length of the signals.

I recommend this link to read more details about MFCCs and there is a useful video tutorial about DTW. Also you can find many articles about DTW, it is a well known measure for the similarity between two time series.

For goal 1.

Measure of similarity is best given by a maximum ratio combiner or matched filter. I am assuming here you don't have any sort of Interference. So you could simply project the received 3 dimensional vector along the "known" user vectors. The one with higher correlation value corresponds to the user.

Now how you come up with these "known" vectors, entirely depends on you data set.

For goal 2.

Try and model the correlation as perturbed with some gaussian noise. Set a confidence interval that makes sense, $$-2\sigma$$ to $$2\sigma$$ around the mean of the gaussian (covers 95% of the uncertainty). The mean of the gaussian would be the norm square of user signal.

A typical approach is:

1. reduce sampling frequency
2. calculate FFT
3. compare FFT with reference FFT
• The FFT doesn't seem to output a single number (based on the Python numpy docs) So in step 3. how does one 'compare' ? – user49593 Jan 11 '18 at 14:17
• Taking the rms value of the difference could yield a value to threshold. Remember to normalize the ffts before subtracting them. You might want to select the relevant frequencies band beforehand. – user6522399 Jan 25 '18 at 11:48