-
Notifications
You must be signed in to change notification settings - Fork 431
Open
Description
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
- AffineTransformation uses
eltype(basedist)to determine its number and parameter type - default eltype of an uniform continuous distribution is Float64
The 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
dln = LogitNormal{Float32}(0f0, sqrt(2f0))
dshifted = dln * 2f0 + 1f0
@test params(dshifted)[1] isa Float32
@test mean(dshifted) isa Float32
Metadata
Metadata
Assignees
Labels
No labels