Skip to content

Commit 1d33a93

Browse files
committed
test: improve test cases for AlphaStable
1 parent 3222471 commit 1d33a93

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

test/runtests.jl

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,20 +76,31 @@ end
7676
sampletypes = [Float32,Float64]
7777
stabletypes = [AlphaStable,SymmetricAlphaStable]
7878
αs = [0.6:0.1:2,1:0.1:2]
79+
betas = [-1:0.5:1,0.0]
80+
sc = 2.0
7981
for sampletype sampletypes
8082
for (i, stabletype) in enumerate(stabletypes)
8183
for α in αs[i]
82-
d1 = AlphaStable=sampletype(α))
83-
s = rand(rng,d1, 200000)
84-
@test eltype(s) == sampletype
84+
for β in betas[i]
85+
d1 = if stabletype == AlphaStable
86+
stabletype=sampletype(α), β=sampletype(β), scale=sampletype(sc))
87+
else
88+
stabletype=sampletype(α), scale=sampletype(sc))
89+
end
90+
s = rand(rng, d1, 10^6)
91+
@test eltype(s) == sampletype
8592

86-
d2 = fit(stabletype, s)
87-
@test typeof(d2.α) == sampletype
93+
d2 = fit(stabletype, s)
94+
@test typeof(d2.α) == sampletype
8895

89-
@test d1.α d2.α rtol=0.1
90-
stabletype != SymmetricAlphaStable && @test d1.β d2.β atol=0.2
91-
@test d1.scale d2.scale rtol=0.1
92-
@test d1.location d2.location atol=0.1
96+
@test d1.α d2.α rtol=0.1
97+
if (stabletype != SymmetricAlphaStable) &&!= 2)
98+
@test d1.β d2.β atol=0.2
99+
end
100+
# the quantile method is less accurate
101+
@test d1.scale d2.scale rtol=0.2 * sc
102+
@test d1.location d2.location atol=0.9 * sc
103+
end
93104
end
94105

95106
xnormal = rand(rng,Normal(3.0, 4.0), 96000)
@@ -119,7 +130,7 @@ end
119130
@test d3.α α rtol=0.2
120131
@test d3.β 0 atol=0.2
121132
@test d3.scale 1 rtol=0.2
122-
@test d3.location 0 atol=0.1
133+
@test d3.location 0 atol=0.2
123134
end
124135

125136
d4 = AlphaSubGaussian=1.5, n=96000)

0 commit comments

Comments
 (0)