A simple GPU based Pearson correlation coefficient finder made using CUDA.
A Pearson correlation is a statistic which measures a linear correlation of a set of points (x,y). The domain of this function is <-1, 1>, where:
- 1 indicates a positive correlation
- 0 indicates no correlation
- -1 indicates a negative correlation
A mathematical formula used to calculate the coefficient:
Image courtesy of Wikipedia
The program calculates in parallel each of the components of above formula. Every sum is calculated and reduced using GPU. This is the most time-demanding process and it's easy to make it parallel. Then, CPU performs a "finishing" process (summing output values of every GPU block) and substitutes every component into the final formula.
X | Y |
---|---|
43 | 99 |
21 | 65 |
25 | 79 |
42 | 75 |
57 | 87 |
59 | 81 |
(sigma)xi * yi = 20485.000000
(sigma)xi^2 = 11409.000000
(sigma)yi^2 = 11409.000000
(sigma)xi = 247.000000
(sigma)yi = 486.000000
r = 0.529809