Reference Guide > C Routines > CORRELATE Function
  

CORRELATE Function
Standard Library function that calculates a simple correlation coefficient for two arrays.
Usage
result = CORRELATE(x, y)
Input Parameters
x—The X array for which the correlation coefficient is calculated. Can be of any data type except string and it must be of the same data type and have the same number of elements as y.
y—The Y array for which the correlation coefficient is calculated. Can be of any data type except string and it must be of the same data type and have the same number of elements as x.
Returned Value
result—The simple product-moment correlation coefficient for x and y.
Keywords
None.
Discussion
CORRELATE calculates the product-moment correlation coefficient of the two arrays that are supplied.
Correlation can be characterized as the probability that values (i.e., the two input arrays) are related. In other words, it measures whether the events in one population are likely to have produced effects in another population. A result of 1.0 indicates a high correlation, while a result of 0.0 indicates no correlation whatsoever.
Example 1
scores_1 = [95,76,60,88,91,97,68,75,82,85] 
scores_2 = [93,77,62,87,90,97,67,77,80,86] 
scores_corr = CORRELATE(scores_1, scores_2) 
PRINT, scores_corr
; PV-WAVE prints:      0.993408
Example 2
seed = 123456
sample_1 = RANDOMU(seed, 128, 128) 
sample_2 = RANDOMU(seed, 128, 128) 
samples_corr = CORRELATE(sample_1, sample_2) 
PRINT, samples_corr 
; PV-WAVE prints:   0.00451351
Example 3
x = DIST(200)
y = x
exact_corr = CORRELATE(x, y)
PRINT, exact_corr
; PV-WAVE prints:       1.00000

Version 2017.1
Copyright © 2019, Rogue Wave Software, Inc. All Rights Reserved.