# 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

2. Select the menu item Data: Import From File: Single ASCII... to import the data <Origin Installation Directory>\Samples\Signal Processing\Coherence.dat. 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. 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. 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

2. Select menu File: Import: Single ASCII... and import the file <Origin Installation Directory>\Samples\Signal Processing\Correlation.dat. 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. 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. 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. 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. 10. Click OK and both X axes now have the same scale. 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. 13. Again, open the menu and click Shift Curve... to bring up the Shift Curve dialog box. Set Value to 49. 14. Click OK to translate the plot. This should align the two signals. 