Skip to content

Commit

Permalink
Fix type bug in Uniform
Browse files Browse the repository at this point in the history
Fixed the bug where `rand(Uniform{T})` did not preserve the type of `Uniform{T}`.
  • Loading branch information
Red-Portal authored May 25, 2024
1 parent f852803 commit 10f1774
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/univariate/continuous/uniform.jl
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ Base.:*(c::Real, d::Uniform) = Uniform(minmax(c * d.a, c * d.b)...)

#### Sampling

rand(rng::AbstractRNG, d::Uniform) = d.a + (d.b - d.a) * rand(rng)
rand(rng::AbstractRNG, d::Uniform{T}) where {T} = d.a + (d.b - d.a) * rand(rng, T)

_rand!(rng::AbstractRNG, d::Uniform, A::AbstractArray{<:Real}) =
A .= Base.Fix1(quantile, d).(rand!(rng, A))
Expand Down

0 comments on commit 10f1774

Please sign in to comment.