|
76 | 76 | sampletypes = [Float32,Float64] |
77 | 77 | stabletypes = [AlphaStable,SymmetricAlphaStable] |
78 | 78 | αs = [0.6:0.1:2,1:0.1:2] |
| 79 | + betas = [-1:0.5:1,0.0] |
| 80 | + sc = 2.0 |
79 | 81 | for sampletype ∈ sampletypes |
80 | 82 | for (i, stabletype) in enumerate(stabletypes) |
81 | 83 | 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 |
85 | 92 |
|
86 | | - d2 = fit(stabletype, s) |
87 | | - @test typeof(d2.α) == sampletype |
| 93 | + d2 = fit(stabletype, s) |
| 94 | + @test typeof(d2.α) == sampletype |
88 | 95 |
|
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 |
93 | 104 | end |
94 | 105 |
|
95 | 106 | xnormal = rand(rng,Normal(3.0, 4.0), 96000) |
|
119 | 130 | @test d3.α ≈ α rtol=0.2 |
120 | 131 | @test d3.β ≈ 0 atol=0.2 |
121 | 132 | @test d3.scale ≈ 1 rtol=0.2 |
122 | | - @test d3.location ≈ 0 atol=0.1 |
| 133 | + @test d3.location ≈ 0 atol=0.2 |
123 | 134 | end |
124 | 135 |
|
125 | 136 | d4 = AlphaSubGaussian(α=1.5, n=96000) |
|
0 commit comments