-
Notifications
You must be signed in to change notification settings - Fork 415
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
Generic truncated normal & exponential #1090
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1090 +/- ##
==========================================
+ Coverage 79.36% 79.62% +0.26%
==========================================
Files 112 113 +1
Lines 5500 5443 -57
==========================================
- Hits 4365 4334 -31
+ Misses 1135 1109 -26
Continue to review full report at Codecov.
|
This looks good to me, but I don't remember what was the decision on return types for sampling so I'll let @andreasnoack give his opinion before moving this forward |
ping @andreasnoack |
@@ -12,6 +12,8 @@ TruncatedNormal | |||
|
|||
### statistics | |||
|
|||
Base.eltype(::Type{<:Truncated{Normal{T},Continuous}}) where {T <: Real} = T |
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'm wondering why this is needed and the generic implementation in
Distributions.jl/src/truncate.jl
Line 76 in 3f4856c
Base.eltype(::Type{Truncated{D, S, T} } ) where {D, S, T} = T |
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 agree, that seems not necessary for me.
I'm coming from #1089 |
I'm also coming from #1089. Any reasons why this PR is still pending? |
I still wonder why/if the definition of In general, as far as I remember, the general policy is that there are no guarantees that |
In general the parameter type doesn't have to match the type of samples. E.g. a Poisson, has a float parameter but the samples are integers. The decision that |
I am very unsure if this is the right approach but it is definitely what is done currently (and also what you implement in this PR when you define |
BTW I just checked and already without this PR, as expected, we have julia> eltype(truncated(Normal(0f0,1f0), 0f0, Inf32))
Float32 so the |
Can we be more flexible about this? Seems like an unnecessary restriction. |
Fixes #1089.
Since the sampler for truncated normal takes samples from
Exponential
, I also modified theExponential
sampler to return values following the parameter type.