I can define and sample from a uniform distribution with Float32
bounds as follows:
using Distributions
dist = Uniform{Float32}(-1.0f0, 1.0f0)
x = rand(dist)
However, the x
here has type Float64
, not Float32
. Is there a way to force rand(dist)
to return a Float32
, other than casting it after the fact?
This behavior seems kind of inconsistent across Distributions.jl. In the following example:
dist = Normal{Float32}(0.1f0, 1.0f0)
y = rand(dist)
y
is Float32
.
Thank you!