Skip to content

Commit 3eec503

Browse files
committed
Remove BernoulliLogit
1 parent 7b5a822 commit 3eec503

File tree

3 files changed

+5
-38
lines changed

3 files changed

+5
-38
lines changed

Diff for: Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ BangBang = "0.4.2"
5959
Bijectors = "0.14, 0.15"
6060
Compat = "4.15.0"
6161
DataStructures = "0.18"
62-
Distributions = "0.23.3, 0.24, 0.25"
62+
Distributions = "0.25.77"
6363
DistributionsAD = "0.6"
6464
DocStringExtensions = "0.8, 0.9"
6565
DynamicHMC = "3.4"

Diff for: src/Turing.jl

-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ export
128128
Flat,
129129
FlatPos,
130130
BinomialLogit,
131-
BernoulliLogit, # Part of Distributions >= 0.25.77
132131
OrderedLogistic,
133132
LogPoisson,
134133
# AdvancedVI

Diff for: src/stdlib/distributions.jl

+4-36
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ Base.maximum(::Flat) = Inf
1616
Base.rand(rng::Random.AbstractRNG, d::Flat) = rand(rng)
1717
Distributions.logpdf(::Flat, x::Real) = zero(x)
1818

19-
# TODO: only implement `logpdf(d, ::Real)` if support for Distributions < 0.24 is dropped
20-
Distributions.pdf(d::Flat, x::Real) = exp(logpdf(d, x))
21-
2219
# For vec support
2320
Distributions.logpdf(::Flat, x::AbstractVector{<:Real}) = zero(x)
2421
Distributions.loglikelihood(::Flat, x::AbstractVector{<:Real}) = zero(eltype(x))
@@ -41,17 +38,13 @@ struct FlatPos{T<:Real} <: ContinuousUnivariateDistribution
4138
end
4239

4340
Base.minimum(d::FlatPos) = d.l
44-
Base.maximum(d::FlatPos) = Inf
41+
Base.maximum(::FlatPos) = Inf
4542

4643
Base.rand(rng::Random.AbstractRNG, d::FlatPos) = rand(rng) + d.l
4744
function Distributions.logpdf(d::FlatPos, x::Real)
4845
z = float(zero(x))
4946
return x <= d.l ? oftype(z, -Inf) : z
5047
end
51-
52-
# TODO: only implement `logpdf(d, ::Real)` if support for Distributions < 0.24 is dropped
53-
Distributions.pdf(d::FlatPos, x::Real) = exp(logpdf(d, x))
54-
5548
# For vec support
5649
function Distributions.loglikelihood(d::FlatPos, x::AbstractVector{<:Real})
5750
lower = d.l
@@ -91,12 +84,7 @@ BinomialLogit(n::Int, logitp::Real) = BinomialLogit{typeof(logitp)}(n, logitp)
9184
Base.minimum(::BinomialLogit) = 0
9285
Base.maximum(d::BinomialLogit) = d.n
9386

94-
# TODO: only implement `logpdf(d, k::Real)` if support for Distributions < 0.24 is dropped
95-
Distributions.pdf(d::BinomialLogit, k::Real) = exp(logpdf(d, k))
96-
Distributions.logpdf(d::BinomialLogit, k::Real) = _logpdf(d, k)
97-
Distributions.logpdf(d::BinomialLogit, k::Integer) = _logpdf(d, k)
98-
99-
function _logpdf(d::BinomialLogit, k::Real)
87+
function Distributions.logpdf(d::BinomialLogit, k::Real)
10088
n, logitp, logconstant = d.n, d.logitp, d.logconstant
10189
_insupport = insupport(d, k)
10290
_k = _insupport ? round(Int, k) : 0
@@ -109,16 +97,6 @@ function Base.rand(rng::Random.AbstractRNG, d::BinomialLogit)
10997
end
11098
Distributions.sampler(d::BinomialLogit) = sampler(Binomial(d.n, logistic(d.logitp)))
11199

112-
# Part of Distributions >= 0.25.77
113-
if !isdefined(Distributions, :BernoulliLogit)
114-
"""
115-
BernoulliLogit(logitp::Real)
116-
117-
Create a univariate logit-parameterised Bernoulli distribution.
118-
"""
119-
BernoulliLogit(logitp::Real) = BinomialLogit(1, logitp)
120-
end
121-
122100
"""
123101
OrderedLogistic(η, c::AbstractVector)
124102
@@ -151,12 +129,7 @@ end
151129
Base.minimum(d::OrderedLogistic) = 0
152130
Base.maximum(d::OrderedLogistic) = length(d.cutpoints) + 1
153131

154-
# TODO: only implement `logpdf(d, k::Real)` if support for Distributions < 0.24 is dropped
155-
Distributions.pdf(d::OrderedLogistic, k::Real) = exp(logpdf(d, k))
156-
Distributions.logpdf(d::OrderedLogistic, k::Real) = _logpdf(d, k)
157-
Distributions.logpdf(d::OrderedLogistic, k::Integer) = _logpdf(d, k)
158-
159-
function _logpdf(d::OrderedLogistic, k::Real)
132+
function Distributions.logpdf(d::OrderedLogistic, k::Real)
160133
η, cutpoints = d.η, d.cutpoints
161134
K = length(cutpoints) + 1
162135

@@ -232,18 +205,13 @@ LogPoisson(logλ::Real) = LogPoisson{typeof(logλ)}(logλ)
232205
Base.minimum(d::LogPoisson) = 0
233206
Base.maximum(d::LogPoisson) = Inf
234207

235-
function _logpdf(d::LogPoisson, k::Real)
208+
function Distributions.logpdf(d::LogPoisson, k::Real)
236209
_insupport = insupport(d, k)
237210
_k = _insupport ? round(Int, k) : 0
238211
logp = _k * d.logλ - d.λ - SpecialFunctions.loggamma(_k + 1)
239212

240213
return _insupport ? logp : oftype(logp, -Inf)
241214
end
242215

243-
# TODO: only implement `logpdf(d, ::Real)` if support for Distributions < 0.24 is dropped
244-
Distributions.pdf(d::LogPoisson, k::Real) = exp(logpdf(d, k))
245-
Distributions.logpdf(d::LogPoisson, k::Integer) = _logpdf(d, k)
246-
Distributions.logpdf(d::LogPoisson, k::Real) = _logpdf(d, k)
247-
248216
Base.rand(rng::Random.AbstractRNG, d::LogPoisson) = rand(rng, Poisson(d.λ))
249217
Distributions.sampler(d::LogPoisson) = sampler(Poisson(d.λ))

0 commit comments

Comments
 (0)