I know there is a correlation function in Q. https://code.kx.com/q/ref/cor/
Is there a “weighted correlation”?
I know there is a correlation function in Q. https://code.kx.com/q/ref/cor/
Is there a “weighted correlation”?
There is no inbuilt weighted correlation, but you can easily implement Pearson Weighted Correlation as follows
wcov: {[x;y;w] w wavg (x-w wavg x)*y-w wavg y} // weighted covariance
wcor: {[x;y;w] wcov[x;y;w]%sqrt wcov[x;x;w]*wcov[y;y;w]} // weighted correlation
-Ajay