One computes a correlation between two sets of numbers of the same size, so corr in the Fortran standard library should work for two 1-D arrays x and y of the same length. The current specification computes the correlation matrix of the rows columns of x(:,:), which is also fine.
I suggest that corr in Fortran be modeled after cor in R, which works with 1 or 2 array arguments. Similarly, cov in Fortran should optionally work with two array arguments.
Agreed – to me the stdlib functions
corr don’t seem to correspond to the standard definitions of covariance and correlation.
It looks like the issue was raised here some time ago.
The original discussion of the code has links to implementations in other languages, which seem more standard.
It may simply be that this is a work in progress?
I implemented most of the functions in
stdlib_stats, and I agree with both of you that
cov should also accept 2 arrays. As @gareth mentioned it, it has been mentioned and discussed a bit in
stdlib issues and PR. Unfortunately I didn’t find the time to progress on it. Your help and ontributions would be much appreciated