-
Notifications
You must be signed in to change notification settings - Fork 182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pearson correlation among elements of an array #191
Conversation
Squashed commit of the following: commit 9cd7538 Author: Vandenplas, Jeremie <[email protected]> Date: Sat May 16 22:48:56 2020 +0200 corr_dev: addition of specs commit 4af1d2d Author: Vandenplas, Jeremie <[email protected]> Date: Sat May 16 22:29:42 2020 +0200 corr_dev: addition of tests for csp and int32 commit aef4416 Author: Vandenplas, Jeremie <[email protected]> Date: Sat May 16 22:29:08 2020 +0200 corr_dev: addition of tests for csp and int32 commit 0e6ec5d Author: Vandenplas, Jeremie <[email protected]> Date: Sat May 16 22:19:56 2020 +0200 corr_dev: clarification commit 1fdabd9 Author: Vandenplas, Jeremie <[email protected]> Date: Sat May 16 22:14:44 2020 +0200 corr_dev: correction of an issue with complex commit 1632355 Author: Vandenplas, Jeremie <[email protected]> Date: Sat May 16 21:41:12 2020 +0200 corr_dev:completed impl commit 1fe73b1 Merge: 9da1d97 ce987d2 Author: Vandenplas, Jeremie <[email protected]> Date: Sat May 16 13:13:46 2020 +0200 Merge remote-tracking branch 'upstream/master' into corr_dev commit 9da1d97 Author: Vandenplas, Jeremie <[email protected]> Date: Sat May 16 12:46:05 2020 +0200 corr_dev: addition of tests for int64 commit d03d828 Author: Vandenplas, Jeremie <[email protected]> Date: Sat May 16 12:22:13 2020 +0200 corr_dev: addition of test for dp complex numbers commit 7901ee2 Author: Vandenplas, Jeremie <[email protected]> Date: Fri May 15 20:18:03 2020 +0200 corr_dev: correction for vector with all elements false commit 2a119c2 Author: Vandenplas, Jeremie <[email protected]> Date: Fri May 15 19:02:12 2020 +0200 corr_dev: done until mask commit 19c1f8e Author: Vandenplas, Jeremie <[email protected]> Date: Fri May 15 16:42:47 2020 +0200 corr_dev: implemented some correlation functions commit ec16e9c Author: Vandenplas, Jeremie <[email protected]> Date: Fri May 15 16:12:13 2020 +0200 corr_dev: init
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks good to me, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise I think it looks good. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing it. I think it looks great now and ready to merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Co-authored-by: Milan Curcic <[email protected]>
Co-authored-by: Milan Curcic <[email protected]>
If there are no other objections/comments to this PR, I will then merge this evening. |
Thank you for your inputs. I'll merge. |
Related to the functions
cov
andvar
As usual, everything can/must be discussed.
Other implementations
Specs:
corr
- Pearson correlation of array elementsDescription
Returns the Pearson correlation of the elements of
array
along dimensiondim
if the corresponding element inmask
istrue
.The Pearson correlation between two rows (or columns), say
x
andy
, ofarray
is defined as:Syntax
result = corr(array, dim [, mask])
Arguments
array
: Shall be a rank-1 or a rank-2 array of typeinteger
,real
, orcomplex
.dim
: Shall be a scalar of typeinteger
with a value in the range from 1 ton
, wheren
is the rank ofarray
.mask
(optional): Shall be of typelogical
and either a scalar or an array of the same shape asarray
.Return value
If
array
is of rank 1 and of typereal
orcomplex
, the result is of typereal
corresponding to the type ofarray
.If
array
is of rank 2 and of typereal
orcomplex
, the result is of the same type asarray
.If
array
is of typeinteger
, the result is of typereal(dp)
.If
array
is of rank 1 and of size larger than 1, a scalar equal to 1 is returned. Otherwise, IEEENaN
is returned.If
array
is of rank 2, a rank-2 array with the corresponding correlations is returned.If
mask
is specified, the result is the Pearson correlation of all elements ofarray
corresponding totrue
elements ofmask
. If every element ofmask
isfalse
, the result is IEEENaN
.Example