-
Notifications
You must be signed in to change notification settings - Fork 423
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 suffstats
and fit_mle
type-generic for Normal{T}
#1560
base: master
Are you sure you want to change the base?
Conversation
suffstats
and fit_mle
type-generic for Normal{T}
ping @devmotion since it started with your PR |
if isnan(mu) | ||
if isnan(sigma) | ||
fit_mle(Normal, suffstats(Normal, x)) | ||
fit_mle(D, suffstats(Normal, x)) | ||
else | ||
g = NormalKnownSigma(sigma) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should find a way to preserve/forward the type of D
in these cases as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which eltype should we pick for D
though, the one of g
or the one of the suffstats?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a conversion in my latest commit, what do you think?
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #1560 +/- ##
==========================================
+ Coverage 85.94% 85.95% +0.01%
==========================================
Files 144 144
Lines 8658 8666 +8
==========================================
+ Hits 7441 7449 +8
Misses 1217 1217 ☔ View full report in Codecov by Sentry. |
Now the behavior is that:
|
In the spirit of #1558, here is a prototype PR that:
x
andw
infit_mle
(they can both beAbstractVector{<:Real}
)NormalStats
(which becomesNormalStats{T}
)fit_mle(Normal{Float32}, x, w)
will return aNormal{Float32}
I haven't added type tests yet, waiting on confirmation from the maintainers that this is a welcome addition. If so, I can implement similar changes for a few more standard distributions.
Note: this PR originated from a discussion with @matbesancon. Looking at
methods(suffstats)
makes it clear that some homogeneization wouldn't hurt there.