Skip to content

Commit

Permalink
fix missing broadcast sqrt in MvTDist rand (#769)
Browse files Browse the repository at this point in the history
* test for size of random samples from MvTDist

* broadcast sqrt in sd adjustment for GenericMvTDist rand
  • Loading branch information
kleinschmidt committed Sep 8, 2018
1 parent 4b0e5fd commit 1edffc7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/multivariate/mvtdist.jl
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ function _rand!(d::GenericMvTDist, x::AbstractMatrix{T}) where T<:Real
y = Matrix{T}(undef, 1, cols)
unwhiten!(d.Σ, randn!(x))
rand!(chisqd, y)
y = sqrt(y/(d.df))
y = sqrt.(y/(d.df))
broadcast!(/, x, x, y)
if !d.zeromean
broadcast!(+, x, x, d.μ)
Expand Down
3 changes: 3 additions & 0 deletions test/mvtdist.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ d = GenericMvTDist(1, Array{Float32}(mu), PDMat(Array{Float32}(Sigma)))
@test typeof(convert(GenericMvTDist{Float64}, d)) == typeof(GenericMvTDist(1, mu, PDMat(Sigma)))
@test typeof(convert(GenericMvTDist{Float64}, d.df, d.dim, d.zeromean, d.μ, d.Σ)) == typeof(GenericMvTDist(1, mu, PDMat(Sigma)))
@test partype(d) == Float32

@test size(rand(MvTDist(1., mu, Sigma))) == (2,)
@test size(rand(MvTDist(1., mu, Sigma), 10)) == (2,10)

0 comments on commit 1edffc7

Please sign in to comment.