Skip to content

Incorrect pdf for Dirichlet distribution #1241

@yurivish

Description

@yurivish

Hello,

I was using Julia to explore statistical distributions and came across what seems to me to be an error in the pdf of the Dirichlet distribution.

julia> using Distributions

julia> beta = Beta(1, 1);

julia> pdf(beta, 0)
1.0

julia> dirichlet = Dirichlet([1, 1]);

julia> pdf(dirichlet, [0, 1])
NaN

My understanding is that the two distributions above are mathematically equivalent, and therefore the results should be the same for both of the pdfs above. The second case uses [0, 1] because the Dirichlet distribution is defined on a simplex.

I believe the behavior of pdf(beta, 0) is correct.

I also noticed a difference in behavior on points outside of the support: the Beta distribution returns zero density, while the Dirichlet function can error or report incredibly large values:

julia> pdf(beta, -0.5)
0.0

julia> pdf(dirichlet, [-0.5, 1.5])
ERROR: DomainError with -0.5:
log will only return a complex result if called with a complex argument. Try log(Complex(x)).

julia> pdf(Dirichlet([1000, 100]), [1, 1])
1.293606521475018e146

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions