KX Community

Find answers, ask questions, and connect with our KX Community around the world.
KX Community Guidelines

Home Forums kdb+ weighted correlation in Q?

  • Laura

    Administrator
    June 7, 2021 at 12:00 am

     

    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

Log in to reply.