4.3.9 Coherence and Correlation

Summary

Coherence measures the degree of linear dependency of two signals by testing for similar frequency components. If two signals correspond to each other perfectly at a given frequency, the magnitude of coherence is 1. If they are totally unrelated coherence will be 0.

Correlation is another measure of the relationship between two signals. A correlation coefficient is used to evaluate similarity. If two signals have a high degree of similarity, the magnitude of the computed correlation coefficient is large. If there is little or no linear relationship between two signals, the magnitude of the coefficient is small.

What You Will Learn

This tutorial will show you how to:

  1. Test coherence and find out the frequency where two signals are in the highest degree of linear dependency.
  2. Perform correlation and find the lag to translate a dataset.

Coherence

  1. Start with a new workbook.
  2. Start with an empty worksheet. Select Help: Open Folder: Sample Folder... to open the "Samples" folder. In this folder, open the Signal Processing subfolder and find the file Coherence.dat. Drag-and-drop this file into the empty worksheet to import it.
    SP Tutorial Coherence 1.png
  3. Select column A, then right-click and select Set As: Y from the shortcut menu. This sets the plot designation for column A to Y.
  4. Highlight the two columns and from the menu select Analysis: Signal Processing: Coherence.... This opens the Coherence: cohere dialog box.
  5. Change the Window Type to Welch, and click OK.
    SP Tutorial Coherence 2.png
  6. Two columns of data are added to the worksheet. Highlight these two new columns and from the menu select Plot > Basic 2D: Line to plot coherence against frequency.
    SP Tutorial Coherence 3.png
  7. Select the Data Reader on the Tools toolbar to read the strongest peak in the graph. The image above shows that at a frequency of 0.25 there is a strong peak, indicating a strong correspondence between the two signals at this frequency.

1D Correlation

  1. Start with a new workbook.
  2. Select menu File: Import: Single ASCII... and import the file <Origin Installation Directory>\Samples\Signal Processing\Correlation.dat.
    SP Tutorial Correlation 1.png
  3. Select column A. Right click on it to open the shortcut menu, then choose item Set As: Y to set this column's plot designation to Y.
  4. Highlight the two columns and from the menu select Analysis: Signal Processing: Correlation.... This opens the Correlation:corr1 dialog box. Accept the default settings.
    SP Tutorial Correlation 2.png
  5. Click OK to perform a correlation on the two signals.
  6. The correlation result and a time lag column are output to the worksheet. Highlight column D, and from the menu select Plot > Basic 2D: Line to plot the result.
    SP Tutorial Correlation 3.png
  7. The Data Reader in the image above shows that at Time = 49, there is a strong positive peak, which means that the second dataset needs to be translated forward 49 units to align these two signals.
  8. Return to the worksheet, highlight column A and B, then from the menu select Plot > Multi-Panel/Axis: Vertical 2 Panel to plot the two signals to two separate graph layers.
    SP Tutorial Correlation 4.png
  9. Double click on the top plot to open the Plot Details dialog box. In the left panel, select Layer 2 (take care not to clear the check box). Go to the Link Axes Scales tab in the right panel and click the Straight (1 to 1) radio button in the X Axis Link group.
    SP Tutorial Correlation 5.png
  10. Click OK and both X axes now have the same scale.
    SP Tutorial Correlation 6.png
  11. To make the datasets movable, delete the lock by clicking on it and choosing Recalculate Mode: None. Click OK if the Reminder Message dialog pops up.
  12. Select the top plot, then select menu Analysis: Data Manipulation: Horizontal Translate to add a vertical line to the layer, together with a triangle button. Click on the triangle button to open a menu and uncheck Keep Tool after Translation. Open the menu again, select Translate Duplication in: New Columns from the menu. Another two columns will be added and the source data of current curve will be copied to these two new columns.
    SP Tutorial Correlation 7a.png
  13. Again, open the menu and click Shift Curve... to bring up the Shift Curve dialog box. Set Value to 49.
    SP Tutorial Correlation 7.png
  14. Click OK to translate the plot. This should align the two signals.
    SP Tutorial Correlation 8.png