Skip to content

Commit ce8f8fd

Browse files
committed
add min/max methods
1 parent 2d6d091 commit ce8f8fd

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "WilliamsonTransforms"
22
uuid = "48feb556-9bdd-43a2-8e10-96100ec25e22"
33
authors = ["Oskar Laverny <oskar.laverny@gmail.com> and contributors"]
4-
version = "0.1.0"
4+
version = "0.1.1"
55

66
[deps]
77
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"

src/WilliamsonTransforms.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import Distributions
1010
import TaylorSeries
1111
import Base.minimum
1212
import Roots
13+
import Base: minimum, maximum
1314

1415
export 𝒲, 𝒲₋₁
1516

@@ -110,12 +111,14 @@ function Distributions.cdf(d::𝒲₋₁, x::Real)
110111
# return 1-rez
111112
end
112113
function Distributions.logpdf(d::𝒲₋₁, x::Real)
113-
ϕ_d = taylor(d.ϕ, x, d.d+1, typeof(x))[end]
114+
ϕ_d = max(taylor(d.ϕ, x, d.d+1, typeof(x))[end],0)
114115
r = (d.d-1)*log(x) - sum(log.(1:(d.d-1)))
115116
return log(ϕ_d) + r
116117
end
117118
function Distributions.rand(rng::Distributions.AbstractRNG, d::𝒲₋₁)
118119
u = rand(rng)
119120
Roots.find_zero(x -> (Distributions.cdf(d,x) - u), (0.0, Inf))
120121
end
122+
Base.minimum(::𝒲₋₁) = 0.0
123+
Base.maximum(::𝒲₋₁) = Inf
121124
end

0 commit comments

Comments
 (0)