Skip to content

No bounds checking in Chi distribution #1497

@pdeffebach

Description

@pdeffebach

From discourse here


julia> pdf(Chi(3), -.5)
ERROR: DomainError with -0.5:
log will only return a complex result if called with a complex argument. Try log(Complex(x)).

Even though pdf should be 0 for x < 0. See wiki.

The problem is a logpdf function that does not check the bounds. See here

logpdf(d::Chi, x::Real) = (ν = d.ν;
    (1 - ν/2) * logtwo + (ν - 1) * log(x) - x^2/2 - loggamma(ν/2)
)

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