Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distributions defined in Turing: is the plan to keep them here? #2298

Open
DominiqueMakowski opened this issue Aug 6, 2024 · 2 comments
Open

Comments

@DominiqueMakowski
Copy link
Contributor

I recently spent some time looking for OrderedLogistic, assuming that it was in Distributions.jl, but actually it was defined directly in Turing

function OrderedLogistic(η, cutpoints::AbstractVector)
return OrderedLogistic{typeof(η),typeof(cutpoints)}(η, cutpoints)
end
Base.minimum(d::OrderedLogistic) = 0
Base.maximum(d::OrderedLogistic) = length(d.cutpoints) + 1
# TODO: only implement `logpdf(d, k::Real)` if support for Distributions < 0.24 is dropped
Distributions.pdf(d::OrderedLogistic, k::Real) = exp(logpdf(d, k))
Distributions.logpdf(d::OrderedLogistic, k::Real) = _logpdf(d, k)
Distributions.logpdf(d::OrderedLogistic, k::Integer) = _logpdf(d, k)
function _logpdf(d::OrderedLogistic, k::Real)
η, cutpoints = d.η, d.cutpoints
K = length(cutpoints) + 1
_insupport = insupport(d, k)
_k = _insupport ? round(Int, k) : 1
logp = unsafe_logpdf_ordered_logistic(η, cutpoints, K, _k)
return _insupport ? logp : oftype(logp, -Inf)
end

Out of curiosity, is there a reason not to move these distributions to Distributions.jl where their documentation might benefit from increased visibility?

@devmotion
Copy link
Member

IIRC I moved a few of them (quite a while ago), and my impression has always been that they should be moved if they are of more general interest.

@yebai
Copy link
Member

yebai commented Aug 6, 2024

We are happy to move more distributions in this repo, and also DistributionsAD to Distributions.jl, particularly the autodiff rules currently in DistributionsAD.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants