Skip to content

Commit 790607d

Browse files
authored
Merge pull request #53 from org-arl/patch-randexp
fix: infinite return value
2 parents 6776f1a + 2331de7 commit 790607d

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-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 = "AlphaStableDistributions"
22
uuid = "f20549b4-2d50-407f-863c-cdd202ba59a3"
33
authors = ["Fredrik Bagge Carlson", "Too Yuen Min"]
4-
version = "1.1.8"
4+
version = "1.1.9"
55

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

src/AlphaStableDistributions.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ function Base.rand(rng::AbstractRNG, d::AlphaStable{T}) where {T<:AbstractFloat}
300300
if α == one(T) && β == zero(T)
301301
return loc + sc * tan(ϕ)
302302
end
303-
w = -log(rand(rng, T))
303+
w = randexp(rng) # exponential random variable with mean 1
304304
α == 2 && (return loc + 2*sc*sqrt(w)*sin(ϕ))
305305
β == zero(T) && (return loc + sc * ((cos((one(T)-α)*ϕ) / w)^(one(T)/α - one(T)) * sin* ϕ) / cos(ϕ)^(one(T)/α)))
306306
cosϕ = cos(ϕ)

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ end
8989
end
9090
s = rand(rng, d1, 10^6)
9191
@test eltype(s) == sampletype
92+
@test any(isinf.(s)) == false
9293

9394
d2 = fit(stabletype, s)
9495
@test typeof(d2.α) == sampletype

0 commit comments

Comments
 (0)