-
Notifications
You must be signed in to change notification settings - Fork 421
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
LogitNormal
disrupts types
#1765
Comments
@devmotion commented on a commit: "The parameter type of a distribution can be retrieved by partype, eltype is supposed to be the (element) type of rand" Computing the mean of distribution, to my understanding, should return the same type as a random number drawn. Moreover, all the uniform continuous distributions which I looked at, enforce the same parametric type as the type of the parameters. This also leads to some strange behaviour such as: Are the terms, concepts, and types involved described somewhere? My expectation would be the Type Hierarchy section of the documentation. However, the parametric types of the distributions and the types of the parameters are not really clarified there. |
julia> eltype(dln)
Float64
julia> typeof(rand(dln))
Float64 So it seems like the bug is in |
LogitNormal
disrupts types
@ParadaCarleton: In my suggestion and proposed commit, I actually changed LogitNormal (and many other distributions) but changing eltype breakes many tests. Currently, many tests seem to expect the eltype of a continuous distribution to be fixed to Float64. My next suggestion would be to make AffineDistribution use |
As a workaround I suggest providing a constructor to |
That's bizarre, to say the least. If that happens, those tests need to be fixed.
Using
That's a pretty ugly hack. Julia functions are supposed to propagate the types of their arguments. |
It's a deliberate design choice that |
Where was that choice made? By who? |
For some number-crunching project we work with Float32 instead of Float64.
Most distributions in Distributions.jl allow to construct a Float32-based version by providing a Type parameter, nice.
However, when I transform a Float32 based LogitNormal distribution (e.g. shift mean by +) the mean applied to the distribution gives me a Float64 instead of a Float32.
The reason is
eltype(basedist)
to determine its number and parameter typeThe normal distribution already defines
Base.eltype(::Type{Normal{T}}) where {T} = T
Should we add such a method to all the other distributions that are based on a parametric type?
Here is a minimal (not) working example
The text was updated successfully, but these errors were encountered: