Skip to content

Commit

Permalink
Introduce error msg for negative alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterwln committed Jan 9, 2025
1 parent 2aba23d commit 2aa166d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/distributions/tensor_dirichlet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ struct TensorDirichlet{T <: Real, N, A <: AbstractArray{T, N}, Ts} <: Continuous
α0::Ts
lmnB::Ts
function TensorDirichlet(alpha::AbstractArray{T, N}) where {T, N}
if !all(x -> x > zero(x), alpha)
throw(ArgumentError("All elements of the alpha tensor should be positive"))
end
alpha0 = sum(alpha; dims = 1)
lmnB = sum(loggamma, alpha; dims = 1) - loggamma.(alpha0)
new{T, N, typeof(alpha), typeof(alpha0)}(alpha, alpha0, lmnB)
Expand Down

0 comments on commit 2aa166d

Please sign in to comment.