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

feat: accessor methods to various distribution #316

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Qazalbash
Copy link

@Qazalbash Qazalbash commented Jan 15, 2025

Hi, this PR fixes #186. I have implemented the accessor methods for the following distributions,

  • Dirac
  • Discrete Uniform
  • Log Normal
  • Triangular
  • Uniform
  • Multivariate Normal

@YeungOnion
Copy link
Contributor

YeungOnion commented Jan 16, 2025

Thanks for working on this. I think it all looks good, but I'm not sure if it's best to leak the implementation of multivariate normal with precision and cov_chol

If you can make these return cloned/owned values, it will be less binding in our API - there is no implication that the struct owns such data. While I have no expectations for this to change, but we're still fairly new.

As far as cost goes, the intended matrix sizes for nalgebra are small (dim<5) will be cheap for potential alloc and copies, so an accessor with cloning is cheaper than computing cholesky decomp or inversion.

A possible intermediate for those who need the precomputed values as is: a take method that returns a struct where all fields are pub containing the same fields as the "taken" MultivariateNormal but none of statistics impls.


EDIT

Quoting myself in #186

non-Copy fields should not clone for immutable accessor, clones should be opt-in by caller

And I just realized that I'm giving you mixed messages on copy being opt-in, aren't I?

🤔 Hmm. I think I need someone else's input here. In what cases might you want to view the precompute outside of the features we have already implemented?

@Qazalbash
Copy link
Author

Hi, I will keep an eye on this PR. Let me know the conclusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

create accessors for all distributions
2 participants