-
Notifications
You must be signed in to change notification settings - Fork 85
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
Make MultivariateNormal
generic over dimension
#209
Conversation
It is a reasonable thing that would preferably have been done before I suppose, since this would be a breaking change. However since the multivariate cases only include this and Dirichlet now it could be worth to do this now instead of later. Since all the usage of multivariate distributions use nalgebra vectors in the end except for creating it using We should of course strive to prevent breaking changes but not be completely averse to it. @YeungOnion whats your input on this? |
I really like the ergonomics of pattern matching and I also think there's a great advantage for use cases where you know the sizes of everything you're using it'll ensure one can't make mistakes, and I could see a great reason to have the static version for performance reasons. I think it's worth the breaking change, but would it not be feasible to |
As a result, it wouldn't be possible to add an implementation of It would be possible to add an implementation of I might have misunderstood what you were asking - please let me know if my response makes sense! |
@riverbl that was what I was asking about and your explanation makes sense to me! Thanks for clarifying. I like the benefits of this, my one caveat is that I think this would establish our API for other multivariate distributions, as I'm also thinking about #208. For multiple variables from the same distribution, their sample space will be the same type, so vectors will work. For multiple variables that are not from the same distribution, their sample space may not be the same type, which would require tuples. And I wish to avoid being close, but not consistent. let [[x, y]] = dist1.sample(&mut rng); // homogeneous types - not valid syntax with this pr, but to demonstrate
let (a, b) = dist2.sample(&mut rng); // heterogeneous types Now that I've written it all down, I like it more as is, but I'll leave this here for posterity or if this sparks other thoughts. My last question is potentially just because I'm shy in this new role. Would it be frowned on if our first release reviving the crate has a breaking change? |
@FreezyLemon mentioned that we should be able to drop the macros feature, and we can keep it as a dev dependency.
I figured since this is related to use of Patch
|
Allow `MultivariateNormal` to have either a runtime known dynamic dimension (as per current) or a compile time known constant dimension. `MultivariateNormal::new_from_nalgebra` has been changed to take the mean and covariance as `OVector` and `OMatrix` rather than `DVector` and `DMatrix`.
Remove `nalgebra` `macros` feature from dependencies and add it to dev dependencies. Bump edition to 2021.
a703414
to
0990bca
Compare
I've rebased and moved the The default dependency resolver for edition 2018 includes features that are specified in dev dependencies when building if the same crate is specified in dependencies without the feature - see https://doc.rust-lang.org/cargo/reference/resolver.html#resolver-versions. If an I've bumped the crate edition to 2021 to avoid this. |
Thanks for looking at the behavior with the 2021 dependency resolver. Quoting myself,
I got over it; I think it's worth changing. @henryjac could you merge this one? I'll add issues to |
For completeness' sake, I'll note two things about this:
|
Allow
MultivariateNormal
to have either a runtime known dynamic dimension (as per current) or a compile time known constant dimension.MultivariateNormal::new
has been changed to take the mean and covariance asOVector
andOMatrix
rather thanVec
.Having the dimension be compile time known allows, for example, pattern matching on the output of sampling the distribution:
See also #168, #177.