-
Notifications
You must be signed in to change notification settings - Fork 184
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
Addition of optional center in API of moment() #161
Conversation
commit 155ddc2 Author: Vandenplas, Jeremie <[email protected]> Date: Sun Mar 22 19:12:07 2020 +0100 rawmoment: update spec commit a365ea0 Author: Vandenplas, Jeremie <[email protected]> Date: Sun Mar 22 18:56:46 2020 +0100 rawmoment: small change in spec commit d955c0c Author: Vandenplas, Jeremie <[email protected]> Date: Sun Mar 22 18:03:49 2020 +0100 rawmoment: correction commit 0480bc1 Author: Vandenplas, Jeremie <[email protected]> Date: Sun Mar 22 17:57:24 2020 +0100 rawmoment: small correction commit fcc6a43 Author: Vandenplas, Jeremie <[email protected]> Date: Sun Mar 22 17:52:30 2020 +0100 rawmoment: cleaning commit c63ea07 Author: Vandenplas, Jeremie <[email protected]> Date: Sun Mar 22 15:48:40 2020 +0100 rawmoment: progress in test files commit ef6deec Author: Vandenplas, Jeremie <[email protected]> Date: Sun Mar 22 15:42:46 2020 +0100 rawmoment: progress commit a31654c Author: Vandenplas, Jeremie <[email protected]> Date: Sun Mar 22 14:03:50 2020 +0100 rawmoment: start tests raw moment commit 78d7fb9 Author: Vandenplas, Jeremie <[email protected]> Date: Sun Mar 22 13:37:02 2020 +0100 rawmoment: addition of test commit 0e93187 Author: Vandenplas, Jeremie <[email protected]> Date: Sun Mar 22 11:55:31 2020 +0100 rawmoment: start to add center in test
I appreciate that the current iteration also supports other centers. Is there any particular reason to prefer raw vs central moments as the default option? In Julia StatsBase.jl the default are central moments. The MATLAB moment is also central.
I am not sure which is more convenient. If central was default, then, for the moment along a specific dimension of a multidimensional array it would be convenient to have a
For the moment of a multi-dimensional array along a specific dimension the currently proposed version seems easier to use, it is however opposite from MATLAB and Julia. With central as default on the other hand, inferring the correct size of the zeros array for raw moments is error-prone. Thoughts? |
Thanks @ivan-pi for the comments. I though about this issue (default: raw or central moment) and wanted to have some discussion about that. I am glad you started it. I choose 'raw moment' as default such that Possible solution:A way to implement easily raw moments would be to allow a scalar So, The API would remain the same. Only the default returned value would change. |
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.
Looks good. I don't have a strong preference regarding the default value for center, so I'll leave it to you and other reviewers to decide.
For consistency with other programming languages used in scientific computing I would prefer to see central moments as default. That way it is easier for users to move between programming languages. If I understand correctly, for the solution you are suggesting, the interface would be the following
Would the type of The remaining option
does not make sense to me in the context of statistical moments. It is in contradiction with the first version above, where the rank of the array and the location of values in the array carry no significance in the moment calculation. It would however make sense for things such as image moments, in which case the |
1) Current default result: central moment: 2) `center`: optional. Must be a scalar if `dim` is not provided, OR Can be a scalar or an array if `dim` is provided.
Following the discussion with @ivan-pi
So, this can be done to compute 2-th raw moment: res = moment( x, 2, center = 0.)
res = moment( x, 2, dim = 1, center = 0.)
res = moment( x, 2, dim = 1, center = zero) !where zero is an array of the same size as res Tests have been implemented for both options. |
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.
Technically this looks good. API wise I don't have strong feelings either way. So if there are no objections, we can merge it.
I restarted the builds, they are failing. Probably due to the conflicts. |
@jvdp1 I got an email where you were asking about some CI failures due to floating point exceptions, but I can't find the comment here. If there is still an issue, let me know, I can have a look at that. |
Sorry for the delay. It looks very good now. I also would prefer center for compatibility with other languages/environment. Thanks for all the work! |
With #163 now in master, I think this needs to be rebased to latest master, and replace calls to
|
@certik thank you for proposing help. I solved this issue and deleted the comment (sorry, I should have update it now). I will rebase the branche. It should be fine then. |
I think you are right, the problem is the same that has been insinuating for a time now. Compilation times are getting too long due to rank-aware routines. It also happens with
and then, setting MAXRANK manually to 7:
I've got for a new complete build:
Note: I've had to manually disable (comment out) some lines of test_mean_f03.f90 for it to compile. Probably we should discuss the compiling times in a new issue, because it will get worse quickly when we add new routines that are made to work with all different ranks. |
Indeed, the problem also appeared with CMake, and it is why we limited the number of ranks to 4 for the CI. |
Seeing the report for the CI, it seems that the flag FYPPFLAGS (to limit the number of ranks to 4 for the CI) is not applied when using the Makefile.manual. I have no idea how to check it. EDIT: The PR #164 should fix this issue. |
I rebased this PR to master and all checks have passed, |
Thank you, great work! Merging into master. |
As discussed in #153
Related to #113
Changed the API of
moment()
fromto
The default returned value before changes was central moments. Now it is raw moments, and central moments if
center
is provided.Note: if
dim
is provided,center
must be an array. Otherwise, it must be a scalar.Comments are welcome, @fiolj @ivan-pi @certik @milancurcic