Skip to content
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

Implement var and std #29

Closed
Tracked by #20
tomwhite opened this issue Jun 29, 2022 · 4 comments · Fixed by #596
Closed
Tracked by #20

Implement var and std #29

tomwhite opened this issue Jun 29, 2022 · 4 comments · Fixed by #596
Labels

Comments

@tomwhite
Copy link
Member

Similar to the implementation of mean.

@tomwhite tomwhite added the good first issue Good for newcomers label Jul 2, 2023
alxmrs added a commit to alxmrs/cubed that referenced this issue Nov 21, 2023
Fixes cubed-dev#29. Here, I use existing cubed operations to implement `var` and `std`. Please let me know if I should reimplement the primitives as pure reductions.
@tomwhite
Copy link
Member Author

The implementation described at https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Parallel_algorithm looks like the one to use here.

alxmrs added a commit to alxmrs/cubed that referenced this issue Sep 26, 2024
Fixes cubed-dev#29. Here, I use existing cubed operations to implement `var` and `std`. Please let me know if I should reimplement the primitives as pure reductions.
@alxmrs
Copy link
Contributor

alxmrs commented Sep 26, 2024

Do you have access to this paper? I think it would be a better algorithm for variance, since it's numerically stable: https://dl.acm.org/doi/10.1145/3221269.3223036 (the wiki article references this paper).

@alxmrs
Copy link
Contributor

alxmrs commented Sep 26, 2024

@alxmrs
Copy link
Contributor

alxmrs commented Sep 26, 2024

tomwhite pushed a commit that referenced this issue Oct 27, 2024
Fixes #29. Here, I use existing cubed operations to implement `var` and `std`. Please let me know if I should reimplement the primitives as pure reductions.

List order follows import order.

Add correction
tomwhite pushed a commit that referenced this issue Oct 27, 2024
Fixes #29. Here, I use existing cubed operations to implement `var` and `std`. Please let me know if I should reimplement the primitives as pure reductions.

List order follows import order.

Add correction
tomwhite added a commit that referenced this issue Oct 28, 2024
…hm (#596)

* Implementation of `std` and `var`.

Fixes #29. Here, I use existing cubed operations to implement `var` and `std`. Please let me know if I should reimplement the primitives as pure reductions.

List order follows import order.

Add correction

* Parameterize tests

* Add test for correction (failing)

* Implement `var` and `std` using a numerically stable parallel algorithm

Passes cubed/tests/test_array_api.py::test_var[False-0.0-0]

Test example of poorly conditioned case for var

* Update status page

* Exclude std and var from JAX tests

---------

Co-authored-by: Alex Merose <al@merose.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants