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

Multinomial randomness #702

Merged
merged 19 commits into from
Jan 25, 2024
Merged

Multinomial randomness #702

merged 19 commits into from
Jan 25, 2024

Conversation

kellertuer
Copy link
Member

@kellertuer kellertuer commented Jan 19, 2024

This PR introduces random for MultinomialSymmetric and MultinomialDoublyStochatstic, which I saw was missing due to a comment here.

Checking the corresponding paper https://ieeexplore.ieee.org/document/8861409
I saw they also introduce MultinoialSPD, which I added here as well. So this short side-track still needs

ToDo

  • riemannian_gradient for Multinomial and the three doubly stochastic ones
  • riemannian_Hessian for MultinomialSymmetric
  • tests
  • read docs

The paper (its tech report we link in the docs to be precise) does state the Hessian for MultinomialDoublyStochastic, but it is quite involved (the symmetric one already is), that I am not sure I can “hack that down” in an efficient and stable way.

@kellertuer kellertuer added new manifold This issue proposes to implement a new manifold extend manifold This issue proposes/asks for new functions to extend an existing manifold preview docs Add this label if you want to see a PR-preview of the documentation labels Jan 19, 2024
Copy link

codecov bot commented Jan 19, 2024

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (95e90c8) 99.57% compared to head (3b3b4e8) 99.57%.

Files Patch % Lines
.../manifolds/MultinomialSymmetricPositiveDefinite.jl 97.36% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #702      +/-   ##
==========================================
- Coverage   99.57%   99.57%   -0.01%     
==========================================
  Files         112      113       +1     
  Lines       10876    10961      +85     
==========================================
+ Hits        10830    10914      +84     
- Misses         46       47       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kellertuer kellertuer marked this pull request as ready for review January 19, 2024 19:52
src/manifolds/Multinomial.jl Outdated Show resolved Hide resolved
src/manifolds/MultinomialSymmetric.jl Outdated Show resolved Hide resolved
src/manifolds/MultinomialSymmetric.jl Outdated Show resolved Hide resolved
src/manifolds/MultinomialSymmetric.jl Outdated Show resolved Hide resolved
src/manifolds/MultinomialSymmetric.jl Outdated Show resolved Hide resolved
@kellertuer
Copy link
Member Author

All things I wanted to implement (and that needed fixing) are implemented (and fixed, e.g. the multinomalsymmetric ones have more than just the symmetric check for points now – again).

So this is no draft any longer, but still needs the tests to be checked and extended.

@kellertuer
Copy link
Member Author

Multinomial is failing on 1.6, but it seems to not be so easy to reproduce, on my machine that works fine.

@mateuszbaran
Copy link
Member

This is weird. is_vector at /ManifoldsBase/src/decorator_trait.jl:481 assumes that the error returned by check_vector has field val but ComponentManifoldError obviously doesn't have it. It looks like a problem with that is_vector perhaps?

@kellertuer
Copy link
Member Author

Might also be that, but even more strange is, that there should not happen any error and on Julia 1.10, 1.9 and 1.6 on my machine it also does not happen.

@mateuszbaran
Copy link
Member

Probably tolerance is too low. It would be more clear if that is_vector didn't try to access val or had a contingency in case it's not present.

@kellertuer
Copy link
Member Author

Yes sure, that would help, but I do not yet directly see, why that is happening yet (also because I can not yet reproduce it here).

@kellertuer
Copy link
Member Author

kellertuer commented Jan 22, 2024

The problem seems to be that this line

https://github.com/JuliaManifolds/ManifoldsBase.jl/blob/65780dc51475b255258dfd35a225f09a0cd2810b/src/ManifoldsBase.jl#L769

either there or in the decorator at

https://github.com/JuliaManifolds/ManifoldsBase.jl/blob/65780dc51475b255258dfd35a225f09a0cd2810b/src/decorator_trait.jl#L481

implicitly assumes that the error at hand is a DomainError (or one of the other simple errors that has msg and val). So this is nothing to fix here, but maybe to rethink in ManifoldsBase. I am also not sure when this might occur, since for now I can not reproduce this on my machine. Here I for now tried to raise the tolerance instead.

edit: Ah I see if error is none the string is still build before returning false, so that might indeed happen, still – the best would be to build a string s in these two places we can warn/info about that is a bit less dependent on the internals of the error at hand.

edit: Ah we could change both lines and any other line with such access to use showerror instead. This is however still an issue for ManifoldsBase then.

@kellertuer
Copy link
Member Author

Great! We have one false-positive, and now just need to write tests for the checks (one SPD matrix that is not multinomial, one actual point on M); similarly for the tangent space.

Maybe we could also improve the errors that are returned, since for now they would only display the wrong Manifold (i.e. that the point is not on the SPD manifold), which might be misleading.

@kellertuer kellertuer mentioned this pull request Jan 24, 2024
15 tasks
@kellertuer
Copy link
Member Author

kellertuer commented Jan 24, 2024

For multinomial SPD I now wrote the tests – and had an idea for random tangents as well, we basically need tangent vectors to multinomial (rows & columns sum to zero) that are symmetric, so we could just pass that to Multinomial and symmetrize afterwards.

edit: ah no, that does not work. Then I do not have a good idea how to generate tangents on multinomalspd

@kellertuer kellertuer added the Ready-for-Review A label for pull requests that are feature-ready label Jan 24, 2024
@kellertuer
Copy link
Member Author

Then I would also consider this to be ready for review and merge.

@kellertuer
Copy link
Member Author

The one line we do not hit is a false-negative (sadly).

Copy link
Member

@mateuszbaran mateuszbaran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few minor comments.

src/manifolds/MultinomialDoublyStochastic.jl Outdated Show resolved Hide resolved
src/manifolds/MultinomialDoublyStochastic.jl Outdated Show resolved Hide resolved
src/manifolds/MultinomialSymmetric.jl Outdated Show resolved Hide resolved
kellertuer and others added 2 commits January 24, 2024 18:52
# Conflicts:
#	NEWS.md
#	src/manifolds/Multinomial.jl
#	src/manifolds/MultinomialDoublyStochastic.jl
#	src/manifolds/MultinomialSymmetric.jl
@kellertuer
Copy link
Member Author

This one is now merged with #700, so we just have to wait for the tests.

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@kellertuer kellertuer merged commit e46a864 into master Jan 25, 2024
24 of 26 checks passed
@kellertuer kellertuer deleted the kellertuer/fix-multinomials branch May 4, 2024 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extend manifold This issue proposes/asks for new functions to extend an existing manifold new manifold This issue proposes to implement a new manifold preview docs Add this label if you want to see a PR-preview of the documentation Ready-for-Review A label for pull requests that are feature-ready
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants