-
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
Traits in statistics::traits
should not require return type be Option
#295
Comments
Also going to say that I'm not tied to this implementation, but I align well to the issue title. I don't think it makes sense to return |
I think your proposal is good. It should be a clear benefit to avoid returning Option if it's statically known to not be needed. Some unordered thoughts:
Footnotes
|
I hadn't thought of this one, but the API I designed doesn't work well for fallible types, I can't
Footnotes |
I'm not sure I understand this point.. can you elaborate or maybe give an example? It seems possible but I'm not sure I understand your proposal correctly. EDIT: I just saw #304. I'll take a look and see if I can't figure it out |
To couple the types for the return of Perhaps I should be using the return of EDIT: on mobile, but within 24h I can push the WIP commit. It won't compile, but it's where I first noticed it; was while implementing moments for the F-distribution. |
Many distributions will have some summary statistics regardless of their parameters so
Option<T>
should not be required, e.g. it is not semantically accurate to require unwrapping the mean of a binomial. Regardless of the sample probability, a validBinomial
type will always have some mean, but student's distribution require at least one dof, cauchy has too much tail and has no mean is never valid.proposed solution
In lieu of generics, we can use associated types for the
statistics::traits::Distribution
trait1. I don't believe this would bound us in terms of generic numerics in the future either, as long as the associated type could support the generic as well, i.e.MeanN
andVarianceN
intostatistics::traits::Distribution
and addCovariance
andEntropy
traitsCovariance
unimplemented!()
overNone
when more correct. Defaulting toNone
when we don't have a simple expression isn't correct (may also be a little more motivating for someone to implement it over panicking).Covariance
on matrices, Cholesky decompositions, vectors, and likely floats.!
before being plain ol'unimplemented!()
before being implemented.Sample code of the traits I propose adding.
Footnotes
I also think renaming it could be helpful, unsure what is better, but since most of them are moments, or central moments, we could make entropy it's own, as entropy is always scalar and have a Moments trait. I think much of this is motivated from reference implementations in Math.NET's interfaces since that's how this project started. ↩
The text was updated successfully, but these errors were encountered: