# Triple correlation in MATLAB

How can I calculate a triple correlation between 3 signals A,B,C (each has 2 million samples)? I know xcorr do it for 2 signals by FFT each signal, multiplication and iFFT back. Since xcorr cannot do it for three signals, I try to do it "manually" by the above algorithm. What I do is FFT each of the 3 signals, multiplicate A.B, which gives a row vector. Then I convert C row vector to C column vector by C' and multiplicate each column of A.B by C. Then iFFT2 back. Unfortunatelly I get a wrong result. The reason I convert C to a column vector is to get a matrix, since triple correlation is calculated according to 2 time delays, and obviously the result should be a matrix rather than a vector as in correlation of the 2 signals, where only a one time delay is present. Thanks in advance!

EDIT:

I will rephrase what I mean. I know xcorr does cross-correlation for 2 signals by FFT each signal, multiplication and iFFT back. Since xcorr cannot do it for three signals, I try to do it "manually" by the above algorithm. So, the "regular" cross-correlation: $$F\left(s_1 \right) = \int_{-\infty}^{\infty}f^* \left(t\right)g\left(t+s_1 \right)dt$$ is a function of 1 variable s1 and therefore is a vector. After FFT on each of the two signals I get 2 vectors in Fourier domain, multiply them element by element, get another vector and by inverse FFT get the cross-correlation, which is a vector.

Now I want to do the same to three signals. Triple correlation is: $$F\left(s_1, s_2 \right) = \int_{-\infty}^{\infty}f^* \left(t\right)g\left(t+s_1 \right)h\left(t+s_2 \right)dt$$ which is a function of s1 and s2 and therefore should be a matrix. After FFT on each of the three signals I get 3 vectors in the Fourier domain. Now, in order to get a matrix as a triple correlation, I need a matrix in Fourier domain as well. But I have 3 row vectors and how exactly can I get a matrix from them? I tried to multiply the first vector by a second one, element by element and then convert the third vector from row to column and multiply between them to get a matrix, but after inverse Fourier transform I get a wrong answer.

EDIT2: I somehow cannot reply to the people that answer below, so I will update my question once again. To Dilip Sarwate: I do a research in quantum optics field (in particular, intensity interferometry) and need to acquire an image of a star from correlations between photons. The information about star's size can be deduced from the cross-correlations of the signals in 2 telescopes (detectors), but in this case the phase information is lost. To get the phase, I perform the measurements in 3 telescopes (detectors) and need to get a triple cross-correlation in order to obtain the information about phase. Finally, when I have the amplitude information (cross-correlation) and phase information (triple correlation) I can, by inverse Fourier transform, get an image (intensity distribution) of the source (star). What I need from cross-correlation measurements is the peak HEIGHT, and not the time delay (since detectors are equidistant from the source and therefore time delay for which photons arrive is 0, more or less). For cross-correlation I get the following kind of graphs: Left graph consists of 2 features: background "triangle" (from non correlating photons) and a "peak" on top of it (from photons that correlate between them). By dividing the maximum of the "peak" and maximum of the "triangle" I get a correlation value, which is between 1 and 2 in my case. The graph on the right represents the case where no photons are correlated, and "peak" does not show up. I have already done with the cross-correlations and now need to calculate correlation value in triple cross-correlations (correlation between signals in three detectors). My signals consist of 2,000,000 points each. Performing correlation by "multiplication and sum, add delay, multiplication and sum, ..." method is taking a long time for such long signals. Therefore, I used an xcorr function in MATLAB, which as I wrote above is much faster, since it workes with Fourier domain. Now I need to get the triple cross correlation, but there is no function (as xcorr) that does it in MATLAB.

• Can you define mathematically what you want the triple correlation result to calculate? What is it, in other words, that you want? – Jim Clay Oct 24 '15 at 13:39
• @Georgiy: Welcome to DSP.SE! Please just edit your question if you want to add more information. Adding such information as an "answer" is contrary to the way the site works and the way people expect questions to be asked. – Peter K. Oct 24 '15 at 19:05
• You can choose to define a triple correlation, but what do you expect to be able to do with the result? With the usual cross-correlation function, one can say things like $x(t)$ and $y(t)$ are most "alike" for a delay of $\tau$ between them (because the cross-correlation function has a peak at $\tau$. So, what does the triple correlation mean (according to you) and what does knowing it get you? – Dilip Sarwate Oct 24 '15 at 20:02